CSS transparency making text transparent - html

bonus props to whoever can figure out why this isn't working. for some reason, my text "ie content, menu, footer" is inheriting the opacity and not sitting at 1 opacity and being fully visable.
I have it set to both be a class and ID as I have tried both ways, and am fairly beginner with CSS actually
<style type="text/css">
div#page {
border:0px solid purple;
width:700px;
margin:0 auto;
padding:5px;
text-align:left;
background-image:url('images/layout.jpg');
}
div {
text-align:center;
}
div#header {
border:2px solid red;
width:695px;
height:30px;
}
div#mostpop {
border:2px solid black;
width:195px;
float:Right;
margin:10px 0px 10px 5px;
height:245px;
background-color:#ffffff;
opacity:0.7;
filter:alpha(opacity=60); /* For IE8 and earlier */
}
div#recent {
border:2px solid black;
width:195px;
float:Right;
margin:10px 0px 10px 0px;
height:245px;
position: relative;
left: 204px;
top: 255px;
background-color:#ffffff;
opacity:0.7;
filter:alpha(opacity=60); /* For IE8 and earlier */
}
div#content {
border:2px solid black;
width:495px;
margin:10px 0 10px 0px;
min-height:500px;
background-color:#ffffff;
opacity:0.7;
filter:alpha(opacity=60); /* For IE8 and earlier */
}
div#footer {
border:2px solid black;
width:695px;
height:30px;
background-color:#ffffff;
opacity:0.7;
filter:alpha(opacity=60); /* For IE8 and earlier */
div.recent p
{
margin:30px 40px;
font-weight:bold;
color:#000000;
opacity:1;
}
div.content p
{
margin:30px 40px;
font-weight:bold;
color:#000000;
opacity:1;
}
div.mostpop p
{
margin:30px 40px;
font-weight:bold;
color:#000000;
opacity:1;
}
div.footer p
{
margin:30px 40px;
font-weight:bold;
color:#000000;
opacity:1;
}
div.header p
{
margin:30px 40px;
font-weight:bold;
color:#000000;
opacity:1;
}
</style>
<div id="page">
<!--<div id="header">Header</div>-->
<div class="mostpop" id="mostpop"><p>Menu</p></div>
<div class="recent" id="recent"><p>Menu</p></div>
<div class="content" id="content"><p>Content</p></div>

Opacity should always inherit from its parent. If you have a div with 50% opacity, and then you set some content within the div to 50% as well, then the resulting inner div will be 25% overall, I'm not completely sure, but I don't think it's possible to make the child elements LESS transparent than its parents.
If you just want the div to have a transparent background, then you don't need to use opacity at all, you can use background: rgba(255, 255, 255, 0.5); for half transparent white, while leaving the foreground text colour intact. There are also workarounds for older versions of IE for this as well, but it should work fine for ie9.

CSS opacity is a bit wonky - once you set a particular opacity on an element, all children of that element are forced to assume at least the same opacity. You can't get around this with child style overrides.
The standard workaround is to create two elements, and position the second absolutely 'over' the first one with a z-index. The lower element gets your partial transparency, the higher one gets your opaque style.
<div style="position: relative">
<div id="transparency" style="position: absolute; top: 0; left: 0">... transparent stuff here </div>
<div id="regular_content" style="position: absolute; top:0;left:0;z-index:1">...</div>
</div>

Related

Hover doesn't work when hovered div is inside another div

I am building webpage with school events. On my webpage I am trying to create div(eventContainer) in which I got another div(eventImgContainer) with an image, and this image when hover do an action, e.g. blur or opacity.
The problem is that it does not respond to hover when div with img is inside any other div.
I was looking at syntax related to hover like ">" or "+" or ', '... nothing seams to work. Any ideas why?
I really want to use only css for this/
html:
<div class="eventContainer">
<div class="eventDescription"><!-- here code with event description--></div>
<div class="eventImgContainer">
<img src="1_Zdjecia/event_1/1.jpg" id="Photo1" title="football">
<p class="hidedText">Go to Gallery</p>
</div>
</div>
CSS:
.eventContainer{
z-index: -1;
position:relative;
margin:auto;
left:0;
right:0;
width:700px;
height:270px;
background-color: #E6E6E6;
border: 4px solid white;
}
.eventImgContainer{
position:relative;
width:375px;
height:217px;
top:20px;
left: 305px;
margin:0;
}
.eventImgContainer img {
position:absolute;
width:100%;
display:block;
}
.eventimgcontainer:hover #Photo1 {
opacity:0.5;
width:400;
}
You last css rules is wrong
.eventImgContainer:hover #Photo1 {
opacity: 0.5;
width: 400px;
}
CSS is case sensitive !
And you shouldn't have negative z-index (you should remove the z-index property or set a positive value).
It works for me when I just change z-index: -1; to z-index: 1;
And your last selector (eventimgcontainer) is wrong, should be "eventImgContainer". But your example works also with this lower case selector. The problem is only your z-index.
.eventContainer{
z-index: 1;
position:relative;
margin:auto;
left:0;
right:0;
width:700px;
height:270px;
background-color: #E6E6E6;
border: 4px solid white;
}
.eventImgContainer{
position:relative;
width:375px;
height:217px;
top:20px;
left: 305px;
margin:0;
}
.eventImgContainer img {
position:absolute;
width:100%;
display:block;
}
.eventImgContainer #Photo1 {
opacity:0.5;
width:400;
}
first of all remove the z-index
.eventContainer{
position:relative;
margin:auto;
left:0;
right:0;
width:700px;
height:270px;
background-color: #E6E6E6;
border: 4px solid white;
}
and then correct the name of the class
.eventImgContainer:hover #Photo1{
opacity:0.5;
width:400;
}

how can solve floating issues

I use CSS to style aside. After applying this style, aside moves to left but I want it at the right of the page. I want aside to have a height that is relational to the container. i.e. I want its bottom margin to touch the top of the footer no matter what is the height of the container.
Style:
aside {
width:260px;
float:right;
border-left:1px dashed #aaa;
padding-right:15px;
padding-left:15px;
text-align:center;
position:absolute;
overflow:auto;
background-color:blue;
border-radius:10px;
box-shadow:0px 0px 7px rgba(0,0,0,0.5);
}
Remove position: absolute;. If you want to keep position: absolute; you can add right: 0; instead.
html,body{
height: 100%;
}
aside {
width:260px;
float:right;
border-left:1px dashed #aaa;
padding-right:15px;
padding-left:15px;
text-align:center;
overflow:auto;
height: 100%;
background-color:blue;
border-radius:10px;
box-shadow:0px 0px 7px rgba(0,0,0,0.5);
}
<aside>I'm at the right side</aside>
As Gustaf said, you have to remove the 'position: absolute' to switch the side. To define the height, all the parents of element, needs to have a defined height, so the children element will have a reference to render your own height, like this:
html, body{
height: 100%;
}
aside {
width:260px;
float:right;
border-left:1px dashed #aaa;
padding-right:15px;
padding-left:15px;
text-align:center;
overflow:auto;
background-color:blue;
border-radius:10px;
box-shadow:0px 0px 7px rgba(0,0,0,0.5);
height: 100%;
}
<html>
<head></head>
<body>
<aside>I'm at the right side</aside>
</body>
</html>

Can't Center Fixed Div

I have read through countless threads on here and others, but have yet to find one that works for me. I am trying to get this darn div to center on the bottom of my page. It is kind of like a footer, but not exactly.
HTML :
<div id="menucontainer">
<div id="menu">
<ul>
<li><img style="width:270px; height:150px; padding-right:25px; padding-top:15px;" src="style/images/UAH.png"></li>
<li>another big test</li>
</ul>
</div>
</div>
CSS :
#menucontainer{
position:fixed;
bottom:0;
}
#menu{
position:fixed;
padding-top:5px;
padding-bottom:15px;
background-color:rgba(0,0,0,0.5);
bottom:0px;
height:200px;
width:1218px;
border:3px solid #000000;
box-shadow:0px -5px 5px #888888;
}
li{
float:left;
margin-left:-10px;
margin-right:-10px;
text-align:center;
list-style:none;
height:190px;
width:300px;
border-left:2px solid #FFFFFF;
border-right:2px solid #FFFFFF;
}
This should be all you need:
#menucontainer {
position: fixed;
bottom: 0;
width: 100%; /* ADD - make sure this container spans the entire screen */
text-align: center; /* Align contents to the center */
}
#menu {
/* remove position: fixed */
display: inline-block;
margin: 0 auto; /* Centers the block */
text-align: left; /* Reset the text alignment */
... /* The rest stays the same */
}
<style>
#menucontainer{
position:absolute;
bottom: -420px;
height: 200px;
margin: 0 auto;
position: relative;
width:1218px;
}
#menu{
position: relative;
padding-top:5px;
padding-bottom:15px;
background-color:rgba(0,0,0,0.5);
bottom:0px;
height:200px;
border:3px solid #000000;
box-shadow:0px -5px 5px #888888;
}
li{
float:left;
margin-left:-10px;
margin-right:-10px;
text-align:center;
list-style:none;
height:190px;
width:300px;
border-left:2px solid #FFFFFF;
border-right:2px solid #FFFFFF;
}
</style
DEMO
I've made some fundamential changes.
Firstly, your #menucontainer. You don't need fixed position - we can use 'sticky footer' technique to make it allways be hitched to the bottom; as we know the width, margin: 0 auto; will help us center it horizontally.
#menucontainer{
position:relative;
width: 1218px;
height:200px;
margin: 0 auto;
}
Secondy, I've added some fake content (.fake-content div) to help you get the idea how this all will look on site.
I've also added clearfix method for proper height rendering of an elements with floated children. More info here (also easy to find anywhere else).
Sticky footer technique has been taken from CSS Tricks site
Any questions? Is that what you was looking for?

Designing select tag

I am trying to design a Select tag as shown in the below figure:
Somehow I managed to design it by wrapping the select tag in a div. but the problem is that when I click the designed arrow, the select tag is not functioning or showing all the lists.
What I am expecting is that when I click on the arrow, the select tag should show all the Options. which is not happening because the arrow section is generated using the parent wrapper elements pseudo elements. I haven't used pseudo element selectors select tag because it seems to be not working.
I can solve this issue using background-image to the parent wrapper but as I have full rights to change the html as I can, I am looking for better approach without using images or javascript i.e using just CSS.
Here is the fiddle.
<div class="select-wrapper">
<select>
<option>EEE</option>
<option>ECE</option>
<option>EIE</option>
</select>
</div>
.select-wrapper {
display:inline-block;
border:1px solid #bbbbbb;
position:relative;
width:120px;
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
margin-top: 10px;
}
.select-wrapper:before{
content: "";
position:absolute;
right: 5px;
top:8px;
border-width: 5px 5px 5px 5px;
border-style: solid;
border-color: #666666 transparent transparent transparent ;
z-index:3;
}
.select-wrapper:after {
content:"";
display:block;
position:absolute;
top:0px;
bottom:0px;
width:20px;
right:0px;
border-left:1px solid #bababa;
background-color:#ededed;
-webkit-border-top-right-radius:5px;
-moz-border-top-right-radius:5px;
border-top-right-radius:5px;
-webkit-border-bottom-right-radius:5px;
-moz-border-bottom-right-radius:5px;
border-bottom-right-radius:5px;
}
select {
width:100%;
background-color:#ededed;
border:none;
outline:none;
padding:0px;
margin:0px;
position:relative;
}
Add pointer-events:none; to your pseudo element classes.
FIDDLE
NB: IE10- doesn't support the pointer-events property (caniuse says that IE11 will, though)
So for IE:
either you'll have to settle with the arrow not being click-able or
you could use use Modernizr to detect whether pointer-events is supported - and if not (IE10-) - revert to the standard built in arrow. (by not using your special styling classes in this case)
.select-wrapper:before{
content: "";
position:absolute;
right: 5px;
top:8px;
border-width: 5px 5px 5px 5px;
border-style: solid;
border-color: #666666 transparent transparent transparent ;
z-index:3;
pointer-events:none; /* <-- */
}
.select-wrapper:after {
content:"";
display:block;
position:absolute;
top:0px;
bottom:0px;
width:20px;
right:0px;
border-left:1px solid #bababa;
background-color:#ededed;
-webkit-border-top-right-radius:5px;
-moz-border-top-right-radius:5px;
border-top-right-radius:5px;
-webkit-border-bottom-right-radius:5px;
-moz-border-bottom-right-radius:5px;
border-bottom-right-radius:5px;
pointer-events:none; /* <-- */
}
Using :after, :before pseudo creates a virtual element and you are overlaying that over your select box, and hence you cannot trigger your select element. The best thing to do is to use background-image here.. I've made the below from scratch, you can check it out.
Demo
.select_wrap {
width: 180px; /* Make sure it is less than the select width */
overflow: hidden; /* Hide default arrow */
border: 2px solid #515151;
border-radius: 5px;
}
select {
width: 220px; /* Your wish, make sure it overflows parent */
padding: 5px;
border: 0;
background: #f5f5f5; /* Fall back */
background: url(http://s2.postimg.org/s44rm4vbp/Untitled_1.png), linear-gradient(to bottom, #f5f5f5 0%,#f6f6f6 47%,#dddddd 100%);
background-repeat: no-repeat;
background-size: 30px 30px, auto auto;
background-position: 150px 0, center center;
}
I used a css3 property.
pointer-events:none
Check the fiddle
This seems to be the closest solution to design the select tag.
Working Fiddle
HTML
<div class="parent">
<div class="select-wrapper">
<select>
<option>EEE</option>
<option>ECE</option>
<option>EIE</option>
</select>
</div>
</div>
CSS
.select-wrapper {
display:inline-block;
position:relative;
width:140px;
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
margin-top: 10px;
overflow:hidden;
background-color:#ededed;
margin-left:-20px;
border-right: 1px solid #bababa;
}
.select-wrapper:before {
content:"";
position:absolute;
right: 5px;
top:8px;
border-width: 5px 5px 5px 5px;
border-style: solid;
border-color: #666666 transparent transparent transparent;
z-index:3;
}
.select-wrapper:after {
content:"";
display:block;
position:absolute;
top:0px;
bottom:0px;
width:20px;
right:0px;
border-left:1px solid #bababa;
background-color:#ededed;
-webkit-border-top-right-radius:5px;
-moz-border-top-right-radius:5px;
border-top-right-radius:5px;
-webkit-border-bottom-right-radius:5px;
-moz-border-bottom-right-radius:5px;
border-bottom-right-radius:5px;
}
select {
width:100%;
background-color:transparent;
border:none;
outline:none;
padding:0px;
margin:0px;
position:relative;
z-index:4;
margin-left:20px;
border: 1px solid #bababa;
border-right: 0px;
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
}
.parent {
display:inline-block;
overflow:hidden;
}
You can also make it more good using :active selector in combination with :after/:before pseudo element selectors. Something like this:
.select-wrapper:active:before{
/** css here **/
}
.select-wrapper:active:after{
/** css here **/
}
Sample fiddle
you can use my custom select
i creat a new design select element based on the orginal
with css and jquery
you can download example here
https://github.com/yanivsuzana/new_select

Overriding main CSS

I'm trying to get the "div.transbox table" to not have the opacity from "div.transbox".
If I try removing the table from the main transbox CSS then I can't get the table to sit on top of "div.transbox".
Any help much appreciated
div.transbox
{
width:1000px;
height:1500px;
margin-left: auto;
margin-right: auto;
background-color:#ffffff;
border:1px solid black;
opacity:0.8;
z-index:-1;
filter:alpha(opacity=80); /* For IE8 and earlier */
}
div.transbox p
{
margin:30px 40px;
font-weight:bold;
color:#000000;
z-index:-1;
}
div.transbox table
{
margin:30px 40px;
font-weight:bold;
color:black;
background-color:#cccccc;
z-index:99;
}
You cannot make child elements "more visible" when the parent element has an adjusted opacity.
opacity's value ranges from 0 to 1, and the properties stack. In the example below, the "real" opacity of the <p> element is not 0.5, but 0.8 * 0.5 = 0.4:
.transbox { opacity: 0.8; }
.transbox p { opacity: 0.5; }