Simon
Simon

Reputation: 10160

CSS div changes position on specific pages

I'm having a strange CSS problem where the main div container on my website shifts to the right when I visit certain pages. This happens even though there is no specific CSS rule to move it

I've uploaded a temp version of my site here: http://myawesometestsite.ddns.net/

When you go to the Publications and Contact page the entire container shifts to the right by a few pixels. The position appears to be correct and unshifted on all other pages

This is the full CSS I'm using:

body {
    background-color: #dcd8cf;
    font-family: Raleway, Arial, sans-serif;
    font-size: 1em;
}

h1 {
    font-size: 1.5em;
    color: #832C00;
    margin-bottom: 30px;
}

h2 {
    font-size: 1.2em;
    color: #832C00;
    margin-top: 30px;
}

h3 {
    font-size: 1em;
    margin-bottom: 5px;
    margin-top: 20px;
}

h4 {
    font-size: 1em;
    font-style: italic;
    margin-top: 0px;
    margin-left: 10px;
    margin-bottom: 5px;
}


.container {
    position: relative;
    left: 50%;
    margin-left: -470px;
    width: 940px;
    border: 1px solid black;
}


/*
Header
*/

header {
    position: relative;
    display: inline-block;
    width: 100%;
    height: 180px;
    background-color: #a63700;
}

header h1 {
    position: absolute;
    font-size: 2.5em;
    color: #e6e6dc;
    top: 50px;
    left: 100px;
    margin: 0px;
}

header h2 {
    position: absolute;
    font-size: 0.77em;
    color: #e6e6dc;
    top: 100px;
    left: 100px;
    margin: 0px;
    opacity: 0.7;
}

header img {
    border: 2px solid #e6e6dc;
    border-radius: 50%;
    max-width: 100%; 
    max-height: 100%;
}

.profileImage {
    display: block;
    margin-left: auto;
    margin-right: auto;
    margin-top: 10px;
    max-width: 150px; 
    max-height: 150px;
}

.skillIcons {
    position: absolute;
    right: 25px;
    top: 15px;
}

.skillIcons img {
    display: inline;
    width: 75px;
    height: 75px;
    padding: 5px;
    margin: 15px;
    opacity: 0.7;
}

/*
Navigation menu
*/

nav {
    position: relative;
    z-index: 1;
    text-align: center;
    letter-spacing: 2px;
    background-color: #a63700;
    height: 50px;
    width: 100%;
}

nav a {
    position: relative;
    top: 20px;
    color: #D1D1C9;
    text-decoration: none;
    padding: 0 30px;
}

nav a:hover {
    border-bottom: solid 1px #e6e6dc;
    padding-bottom: 3px;
}

.navSelected {
    text-shadow:0px 0px 1px white;
    color: white;
}



/*
Main content
*/

main {
    position: relative;
    background-color: white;
    padding: 10px;
}


/*
Footer
*/

footer {
    position: relative;
    color: #e6e6dc;
    background-color: #a63700;
    font-size: 10pt;
    padding: 10px;
}

.leftFooter ul {
    padding-left: 0px;
}

.leftFooter li {
    display: inline;
    list-style-type: none;
}

.leftFooter li a {
    color: #e6e6dc;
    text-decoration: none;
}

.leftFooter li + li:before {
    color: #e6e6dc;
    content: "|";
    padding: 10px;
}

.rightFooter {
    position: absolute;
    right: 10px;
    top: 4px;
}

.rightFooter img {
    display: inline;
    max-width: 30px;
    max-height: 30px;
    vertical-align: middle;
    margin-top: -3px;
}

.copyright {
    font-size: 1em;
}


/*
Home page
*/




/*
Publications page
*/

.hangingIndent {
    padding-left: 1.5em;
    text-indent:-1.5em;
}

.publications h2 {
    margin-top: 50px;
}


/*
Code page
*/

.codeProjects a {
    color: #a63700;
    text-decoration: none;
}

.codeProjects a:hover {
    text-decoration: underline;
}

.codeProjects p {
    margin-left: 10px;
}


/*
CV page
*/

.cvContainer {
    width: 90%;
    margin: 0 auto;
}

.cvEntry {
    margin-bottom: 30px;
    margin-left: 20px;
    margin-right: 20px;
}

.sectionHeading {
    width: 100%;
    border-bottom: 1px solid #000;
}

.alignLeft {
    display: block;
    float: left;
    text-align: left;
    width: 80%;
    margin-top: 10px;
}

.alignLeft p {
    font-size: 1em;
}

.alignLeftSub {
    margin-top: -10px;
    margin-left: 20px;
}

.alignRight {
    display: block;
    float: right;
    text-align: right;
    width: 20%;
    margin-top: 10px;
}

.clear {
    clear: both;
}


/*
Contact page
*/

.contactInfo {
    margin-left: 20px;
}

.contactInfo img {
    display: inline;
    max-width: 30px; 
    max-height: 30px;
    vertical-align: middle;
}

.emailHidden {
    display: none;
}

.contactInfo a {
    margin-left: 5px;
    color: #a63700;
    text-decoration: none;
}

.contactInfo #emailAddress {
    margin-left: 2px;
}

.contactInfo #emailAddress a {
    margin-left: 8px;
}


/*
Media queries
*/


@media screen and (max-width : 940px) {

    .container {
        position: relative;
        left: 0px;
        margin: 0px;
        width: 100%;
    }

    header h1 {
        left: 5%;
        margin: 0px;
    }

    header h2 {
        left: 5%;
        margin: 0px;
    }

    .skillIcons img {
        max-width: 70px;
        max-height: 70px;
        margin-left: 5px;
        margin-right: 0px;
    }

}

@media screen and (max-width : 800px) {

    header h1 {
        display: none;
    }

    header h2 {
        display: none;
    }

    .skillIcons img {
        display: none;
    }

    nav {
        height: 150px;
    }

    nav a {
        display: block;
    }

    nav a:hover {
        border-bottom: none;
        padding-bottom: 0px;
    }

}

@media screen and (max-width : 600px) {

    .rightFooter {
        position: relative;
        display: block;
        margin-left: 10px;
    }

}

I don't believe there's anything in here that's causing the container to shift for just those 2 pages but maybe I'm missing something. Anyone have any idea whats causing this?

Upvotes: 0

Views: 47

Answers (2)

ScaisEdge
ScaisEdge

Reputation: 133400

The lenght of the pages create a vertical scroll bar. Publication and contact are small then the other are more big then the screen. for fix this you need an overflow-y set to scroll;

body {
 overflow-y: scroll;
}

Upvotes: 1

xecute
xecute

Reputation: 455

Add "overflow-y: scroll;" to your "body" selector. It should look like this in your CSS:

body {
    background-color: #dcd8cf;
    font-family: Raleway, Arial, sans-serif;
    font-size: 1em;
    overflow-y: scroll;
}

Upvotes: 1

Related Questions