How to make a wordpress div align to the top of the page?

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:

Read More
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!

Related posts

1 comment

  1. 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 */
    

Comments are closed.