2013-12-15 230 views
1

我的頁面頂部有一個導航欄,位置是固定的,但是我想讓下面的內容最終被導航欄覆蓋。頁面內容被導航欄覆蓋

Screenshot of Problem

這裏的HTML:

<html> 
<head> 
    <title>A Plus Graphing</title> 
    <link rel="stylesheet" 
     type="text/css" 
     href="index.css"/> 
</head> 
<body> 
<div id="all"> 
    <div id="header"> 
    <div class="header_container"> 
     <h1 class="heading"><b class="a_main">A+</b> Graphing</h1> 

     <ul id="top_nav"> 

     <li class="nav_item"><a href="ourmission.html">Our Mission</a></li> 
     <li class="nav_item"><a href="about.html">About</a></li> 
     <li class="nav_item"><a href="contact.html">Contact</a></li> 
     <li class="rfloat"><a href="register_main.html">Sign Up</a></li> 
     </ul> 


    </div> 
    </div> 
    <div id="content"> 
    <div class="global_container"> 
     <b class="welcome">Welcome to <b class="a">A+</b> Graphing!</b> 
     <div class="login_links"> 
     <a class="login_button" href="teacher_login.html">Teacher Login</a> <a class="login_button" href="student_login.html">Student Login</a> 
     </div> 
     <p class="intro_p">A+ Graphing is designed to introduce technology in the classroom and cut down teacher grading time.<br/> 
     <a href="about.html">Learn More</a></p> 

    </div> 
    </div> 

    <div class="footer_container"> 
    A Harsh Mehta and Kevin Turner Production 
    <div id="donate_main"> 
     <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"> 
     <input type="hidden" name="cmd" value="_s-xclick"> 
     <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHLwYJKoZIhvcNAQcEoIIHIDCCBxwCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYAg5+k39g7pV5uiP/DTT7u0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uKRU9LJbPZOqo+Htdn0Q4L9UU+DsMFa2HQ==-----END PKCS7----- 
    "> 
     <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> 
     <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> 
     </form> 
    </div> 
    </div> 

</div> 
</body> 
</html> 

和CSS:`

#header { 
    position: fixed; 
    left: 0px; 
    right: 0px; 
    top: 0px; 
    display: block; 
    background-color: #F2EEEE; 
    height: 51px; 
    width: 100%; 
} 

body { 
    font-family: arial, sans-serif; 
    height: 100%; 

} 
#all { 
height: 100%; 
} 

body a { 
    color: red; 

} 
html { 
height: 100%; 
} 
.a_main { 
    color: red; 
} 

.heading { 
    font-size: 20px; 
    float: left; 
} 

.header_container { 
    margin-left: auto; 

    margin-right: auto; 

    width: 700px; 
    height: 51px; 
} 


.header_teacher { 
    margin-left: auto; 

    margin-right: auto; 

    width: 1200px; 
    height: 51px; 
} 

body ul { 
    list-style-type: none; 
    float: left; 
} 

#top_nav a { 
text-decoration: none; 
color: black; 


} 

#top_nav a:hover { 
    text-decoration: none; 
    border-bottom: 5px solid red; 

} 

#top_nav li { 

    display: block; 
    float: left; 
    margin-left: 50px; 

} 

#content { 
    margin-top: 100px; 

} 

#content { 
    margin-left: auto; 
    margin-right: auto; 
    margin-bottom: 0; 
    margin-top: 0; 
    width: 400px; 
    min-height: 100px; 
} 

.global_container { 
position: absolute; 
} 

.welcome { 
    font-size: 30px; 
} 

.a { 
    color: red; 
} 



.login_button { 
    background-color: red; 
    color: white; 
    border-radius: 15px; 
    text-decoration: none; 
    padding: 5px 10px 5px 10px; 
} 

.intro_p { 
    margin-top: 60px; 
    margin-bottom: 300px; 
} 


#donate_main { 
    float: right; 
} 


.login { 

} 


#info_container { 
    margin-bottom: 350px; 
} 
.login_links { 
    margin-left: auto; 
    margin-right: auto; 
    margin-bottom: 0; 
    margin-top: 20px; 
    width: 300px; 
} 

.footer_container { 
margin-left: auto; 
color: grey; 
border-top: 1px solid grey; 
padding-top: 10px; 
font-size: 15px; 
    margin-right: auto; 
    margin-bottom: 0; 
    margin-top: 20px; 
    width: 700px; 
} 



.login_container { 
    margin-top: 50px; 
    border: 1px solid grey; 
    border-radius: 15px; 
    box-shadow: 5px 5px 5px 5px #888; 
    width: 450px; 
    margin-left: -5em; 
    margin-bottom: 350px; 
    padding: 20px 50px 50px 30px; 
} 

.login_class { 
border-bottom: 1px solid grey; 
} 

.username { 
    width: 300px; 
    height: 20px; 
} 

.password { 
    width: 300px; 
    height: 20px; 
} 

.username2 { 
    width: 300px; 
    height: 30px; 
} 

.password2 { 
    width: 300px; 
    height: 30px; 
} 

.inline_info1 { 
    float: left; 
    width: 200px; 

} 

inline_info { 
    float: left; 
} 

.apple{ 
    margin-top: 20px; 
} 

.student { 
    margin-top: 30px; 
} 

#register_content { 

margin-bottom: 200px; 
} 

.main_inner { 
    margin-bottom: 300px; 
} 

.test_make { 
    margin-top: 100px; 
    margin-left: auto; 
    margin-right: auto; 
    margin-bottom: 0; 
    width: 400px; 
} 

.list_item { 
    display: inline-block; 
    margin-right: 250px; 
    width: 150px; 
} 


#quizes_main_list { 
    width: 90%; 
} 

.inner_list{ 
    width: 100%; 
} 

.greeting_head { 
    width: 100%; 
    text-align: center; 
} 

.view_quiz { 
    color: white; 
    background-color: red; 
    padding-left: 10px; 
    padding-right: 10px; 
    padding-bottom: 5px; 
    padding-top: 5px; 
    border-radius: 15px; 
} 

#quizes_main_list a { 
    text-decoration: none; 

} 

.quiz_item { 
    margin-bottom: 50px; 
} 

.tests { 
    margin-top: 100px; 
} 

.tests a{ 
    text-decoration: none; 
} 

.quiz_main { 
    margin-top: 200px; 

} 

#main { 
    border: 1px solid grey; 
    padding-bottom: 25px; 
    padding-top: 25px; 
    padding-left: 100px; 
    padding-right: 100px; 
    border-radius: 15px; 
     box-shadow: 5px 5px 5px 5px #888; 
} 

.results_main { 
    margin-top: 100px; 
} 


.score { 
    font-size: 50px; 
} 

.results_green { 
    color: green; 
    font-size: 60px; 
} 

#question_stat { 
    float: left; 
} 

#grades_main_list { 
    margin-top: 50px; 
    width: 90%; 
} 

.link_nav { 
    margin-top: 100px; 
} 

.link_inner { 
color: white; 
background-color: red; 
border-radius: 15px; 
padding-top: 5px; 
padding-bottom: 5px; 
padding-left: 10px; 
padding-right: 10px; 
} 

.global_content a{ 
    text-decoration: none; 
} 

.inner_list { 
    margin-bottom: 30px; 
    border-bottom: 1px solid grey; 
    padding-bottom: 20px; 

} 

.quiz_item { 
    width: 100%; 
} 

.inline_info a{ 
    color: white; 
} 

.inline_info1 a{ 
    color: white; 
}` 

預先感謝任何幫助。

回答

2

你已經做了頂部0

保證金這是從您的代碼。只需刪除一行說margin-top:0;

#content { 
    margin-top: 100px; 

} 

#content { 
    margin-left: auto; 
    margin-right: auto; 
    margin-bottom: 0; 
    margin-top: 0; //remove this line 
    width: 400px; 
    min-height: 100px; 
} 
+0

謝謝,這是有效的。但有沒有辦法做到這一點,沒有指定內容的頂部邊距?我用導航欄看到的其他網站沒有這樣的事情。 – user2489946

1

我通過您的代碼搜索,試圖找出造成這種情況的原因。既然你漂浮了你的標題,我想我可以使用clear:both;來修復它,但那不起作用。

現在,添加margin-top:50px;將做的伎倆。

#content{ 
    margin-top:50px; 
} 

我還添加了z-index:10到你的頭所以它會站在所有內容的前面。我認爲它看起來更好;)

#header{ 
    z-index:10; 
} 

JSFIDDLE

0

我有同樣的問題。無法回想起我最終看到答案的地方,但我通過轉到故事板並選擇相關視圖控制器來修復它,然後選擇了屬性檢查器。在「視圖控制器」部分下,找到「延伸邊線」,然後根據需要取消選擇「頂部條形」下或「底部條形」下的選擇。不知道爲什麼這些不被默認取消。