2014-01-09 33 views
1

爲什麼標題導航會隨着瀏覽器大小調整而中斷?如何解決它?我嘗試過不同的方式,但我沒有發現問題!我請求某人解釋並解決問題。請幫忙。標題導航中斷瀏覽器調整大小

HTML

<!DOCTYPE> 
<html="en"> 
    <head> 
     <title>NewsHour24</title> 
     <link rel="stylesheet" type="text/css" href="style.css"> 
    </head> 
    <body> 
     <header> 
      <div class="logo"> 
       <img src="imgs/logo.png" alt="News Hour 24 logo"/> 
      </div> 
      <nav> 
      <div class="header-nav"> 
       <ul> 
        <li><a href="#">Home</a></li> 
        <li><a href="#">News</a></li> 
        <li><a href="#">Technology</a></li> 
        <li><a href="#">Health</a></li> 
        <li><a href="#">Sports</a></li> 
        <li><a href="#">Education</a></li> 
        <li><a href="#">Entertainment</a></li> 
        <li><a href="#">Support</a></li> 
        <li><a href="#">Sign Up</a></li> 
       </ul> 
      </div> 
      </nav> 
     </header>   <!-------------*Header ends here*--------------> 

     <div class="content-area"> 
      <div class="content"> 
       <h1>News Hour 24</h1> 
       <p>NH24 is a free online NEWS site. NH24 stands for News Hour 24. Our aim is to circulate truth,unbiased and latest news of 24 hours.NH24 covers all news </p> 
       <p>You can easily update and share news with us.Your collaboration is our expectation</p> 

       <h3>header3</h3> 
       <p>paragraph paragraph paragraph</p> 
      </div> 

      <footer> 

      <p>Footer</p> 

      <ul> 
       <li><a href="#">Home</a></li> 
        <li><a href="#">News</a></li> 
        <li><a href="#">Technology</a></li> 
        <li><a href="#">Health</a></li> 
        <li><a href="#">Sports</a></li> 
        <li><a href="#">Education</a></li> 
        <li><a href="#">Entertainment</a></li> 
        <li><a href="#">Support</a></li> 
        <li><a href="#">Sign Up</a></li> 
      </ul> 
      </footer> 
     </div> 
    </body> 

</html> 

CSS:

/** 
    * html5doctor.com Reset Stylesheet v1.6.1 (http://html5doctor.com/html-5-reset-stylesheet/) 
    * Richard Clark (http://richclarkdesign.com) 
    * http://cssreset.com 
    */ 
    html, body, div, span, object, iframe, 
    h1, h2, h3, h4, h5, h6, p, blockquote, pre, 
    abbr, address, cite, code, 
    del, dfn, em, img, ins, kbd, q, samp, 
    small, strong, sub, sup, var, 
    b, i, 
    dl, dt, dd, ol, ul, li, 
    fieldset, form, label, legend, 
    table, caption, tbody, tfoot, thead, tr, th, td, 
    article, aside, canvas, details, figcaption, figure, 
    footer, header, hgroup, menu, nav, section, summary, 
    time, mark, audio, video { 
    margin:0; 
    padding:0; 
    border:0; 
    outline:0; 
    font-size:100%; 
    vertical-align:baseline; 
    background:transparent; 
    } 
    body { 
    line-height:1; 
    } 
    article,aside,details,figcaption,figure, 
    footer,header,hgroup,menu,nav,section { 
    display:block; 
    } 
    nav ul { 
    list-style:none; 
    } 
    blockquote, q { 
    quotes:none; 
    } 
    blockquote:before, blockquote:after, 
    q:before, q:after { 
    content:''; 
    content:none; 
    } 
    a { 
    margin:0; 
    padding:0; 
    font-size:100%; 
    vertical-align:baseline; 
    background:transparent; 
    } 
    /* change colours to suit your needs */ 
    ins { 
    background-color:#ff9; 
    color:#000; 
    text-decoration:none; 
    } 
    /* change colours to suit your needs */ 
    mark { 
    background-color:#ff9; 
    color:#000; 
    font-style:italic; 
    font-weight:bold; 
    } 
    del { 
    text-decoration: line-through; 
    } 
    abbr[title], dfn[title] { 
    border-bottom:1px dotted; 
    cursor:help; 
    } 
    table { 
    border-collapse:collapse; 
    border-spacing:0; 
    } 
    /* change border colour to suit your needs */ 
    hr { 
    display:block; 
    height:1px; 
    border:0; 
    border-top:1px solid #cccccc; 
    margin:1em 0; 
    padding:0; 
    } 
    input, select { 
    vertical-align:middle; 
    } 

    /*-------------------------------------CSS RESET ENDS----------------------------*/ 

    body { 

     background-color: #7CB038; 
     width:auto; 
    } 
    header { 

     width:auto; 
     background:red; 
     height: 150px; 
    } 
    .logo{ 

     float: left; 
     clear: both; 
     margin:10px 5px 1px 110px; 
     width:200px; 
     height:66px; 

    } 

    nav { 
     display:block; 
     padding:0; 
     font-size: 1.3em; 
     text-align:center; 
     padding:0; 
     list-style-type:none; 
     margin: 0px 5px 10px 0px; 
     height:50px; 



    } 
    nav ul li { 

     display: inline; 
     border-right:5px solid #fff ; 
     padding:10px; 

      } 

    nav a{ 
     display:inline-block; 
     text-decoration: none; 
     color:white; 
     display:inline-block; 

    } 

    .content-area{ 
     margin: 0 auto; 
     font-family: sans-serif; open-sans; 
     width:60%; 
    } 
+0

如何在菜單中出現窗口調整大小...? – Manoj

+0

請不要在css中使用px,請在css中使用%,這樣可以避免在小屏幕中出現中斷並適合 –

回答

0

如果你希望你的菜單不破,設定一個固定的寬度。

更新小提琴 - http://jsfiddle.net/begtw/6/

  • 刪除標籤,你不需要
  • 改變了一些class ES以id就做(如元素你div#content-area將以每股所以有一個獨特的頁面每頁使用id更有意義)
  • 直接將徽標id添加到徽標圖像。圖像被位於左側

HTML

<header> 
     <img src="imgs/logo.png" id="logo" alt="News Hour 24 logo" /> 
     <nav id="nav-header"> 
      <ul> 
       <li><a href="#">Home</a></li> 
       <li><a href="#">News</a></li> 
       <li><a href="#">Technology</a></li> 
       <li><a href="#">Health</a></li> 
       <li><a href="#">Sports</a></li> 
       <li><a href="#">Education</a></li> 
       <li><a href="#">Entertainment</a></li> 
       <li><a href="#">Support</a></li> 
       <li><a href="#">Sign Up</a></li> 
      </ul> 
     </nav> 
    </header> 

CSS - 固定的寬度。 #logo絕對定位。

nav#nav-header { 
    display:block; 
    padding:0; 
    font-size: 1em; 
    padding:0; 
    list-style-type:none; 
    margin: 15px 5px 10px 160px; /*Large left margin to fit #logo*/ 
    height:50px; 
    float: left; 
    width: 1100px; 
} 

#logo{ 
    position: absolute; 
    left: 10px; top: 10px; 
} 

這將修復您的菜單。您可能需要更小的屏幕尺寸的更多靈活性:)但是,您可以玩一玩,並將其製作成您自己的遊戲。

山姆

+0

是不是可以將問題徽標修復爲div,而不是在導航中?

great

+0

現在浮動問題:left對於LOGO,float:right;導航 – great

+0

我已經用新的小提琴編輯了我的帖子。我會推薦這樣的東西。 – misterManSam