Reputation: 841
I'm building a page template with a transparent header, and I'm trying to make the #content
div align to the very top of the page, underneath the header.
I've tried css such as:
position:absolute;
top:0;
left:0;
and so far none of it has worked..
Here is my page template stylesheet below, and the page in question is:
.wrapper {
min-width: 100%;
height: auto !important;
}
.header {
background-color:transparent;
width: 75%;
max-width: 75%;
height: 40px;
padding-top: 32px;
padding-bottom:32px;
margin-right: auto;
margin-left: auto;
}
#content {
position: absolute;
top:0;
left:0;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
font-weight: light;
color: #ffffff;
background-color: #ffffff;
height: auto;
width: 100%;
max-width:100%;
min-width: 960px;
margin-top: -50px;
margin-left: auto;
margin-right: auto;
text-align: left;
line-height: 30px;
}
Any advice as to what I'm doing wrong would be greatly appreciated.
Thanks!
Upvotes: 1
Views: 693
Reputation: 371023
Try this:
#content {
position:absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.header {
z-index: 2;
position: absolute;
/* background-color: transparent; <-- not necessary */
width: 75%;
max-width: 75%;
height: 40px;
padding-top: 32px;
padding-bottom: 32px;
/* margin-right: auto; <-- not necessary */
/* margin-left: auto; <-- not necessary */
left: 50%; /* new; center header horizontally */
transform: translateX(-50%); /* new; fine tune horizontal centering */
Upvotes: 1