I want to try to code a fixed-header that is a bit transparent.
Any ideas, sample code, tutorials? I want to achieve it with CSS only, if possible. Playing with the opacity (CSS3) is needed, I guess.
You can try to add transition for #header element via changing of the opacity value (just for example). Or you can change top value: when header is visible -> top: 0 , and when header is hidden -> top: -100px (example value, should be equal or more then header height). Save this answer. Show activity on this post.
Step 1: create a header the same way you usually do — don't forget that it needs to be sticky. Step 2: don't choose the background for the part where the header is (setting the rgba to 255,255,255,0 or 0,0,0,0 can also be used to set the background to transparent). Step 3: publish the header as you normally would.
Full screen jsFiddle: http://fiddle.jshell.net/NathanJohnson/LrNBt/show/
jsFiddle: http://jsfiddle.net/NathanJohnson/LrNBt/
<div id="header">
<div id="header-content">
<h1>Here is some heading text :)</h1>
<p>Here is some more content of the header...</p>
</div>
</div>
body {
font-family: arial, sans-serif;
padding: 0;
margin: 0;
}
#header {
background-color: black;
/*Opacity start*/
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=80);
-moz-opacity: 0.80;
-khtml-opacity: 0.8;
opacity: 0.8;
/*Opacity end*/
color: white;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 150px;
padding: 0;
margin: 0;
}
#header #header-content {
margin: 10px;
}
rgba()
instead of opacity
:#header {
background-color: rgba(0, 0, 0, 0.8);
color: white;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 150px;
padding: 0;
margin: 0;
}
#header #header-content {
margin: 10px;
}
I hope this helps.
Use Firebug to analyze their code:
#header {
left: 0;
position: fixed;
top: 0;
width: 100%;
z-index: 90;
background: url("../images/bg-header.png") repeat-x scroll 0 0 transparent;
height: 247px;
}
Instead of using an image use:
background: #000;
filter:alpha(opacity=50);
-moz-opacity:0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With