Html CSS div更改特定页面上的位置

Html CSS div更改特定页面上的位置,html,css,Html,Css,我遇到了一个奇怪的CSS问题,当我访问某些页面时,我网站上的主div容器会向右移动。即使没有特定的CSS规则来移动它,也会发生这种情况 我已在此处上传了我网站的临时版本: 当您转到“出版物和联系人”页面时,整个容器向右移动几个像素。该位置在所有其他页面上显示为正确且未移动 这是我正在使用的完整CSS: body { background-color: #dcd8cf; font-family: Raleway, Arial, sans-serif; font-size:

我遇到了一个奇怪的CSS问题,当我访问某些页面时,我网站上的主div容器会向右移动。即使没有特定的CSS规则来移动它,也会发生这种情况

我已在此处上传了我网站的临时版本:

当您转到“出版物和联系人”页面时,整个容器向右移动几个像素。该位置在所有其他页面上显示为正确且未移动

这是我正在使用的完整CSS:

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;
    }

}
我不相信这里有任何东西会导致容器移动到这两页,但也许我遗漏了什么。有人知道这是什么原因吗?

将“溢出:滚动;”添加到“正文”选择器中。在CSS中应该是这样的:

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

页面的长度会创建一个垂直滚动条。出版物和联系人比其他人小,比屏幕大。为了解决这个问题,你需要一个overflow-y设置来滚动

body {
 overflow-y: scroll;
}

我看不到Firefox中的错误/bug我应该提到我正在用chrome进行测试,对不起