2011-03-06 214 views
0

我正在爲我的客戶開發一個網站,我遇到的問題是每當您調整窗口大小時,導航欄上的按鈕都會一起擠壓。問題的原因對我來說並不明顯,所以我來這裏尋求一些幫助。當瀏覽器窗口最大化時,navi欄對我來說也很適合,但對於我的客戶,她在頁面中間看到了twitter按鈕。我認爲這只是一個解決問題,因爲她的屏幕比我的屏幕小,但是有沒有辦法解決這個問題?CSS/HTML導航欄問題

網站:
the crue cart

HTML

<title>the crue cart</title> 

    <link rel="shortcut icon" href="images/favicon.png"> 
    <link rel="alternate" type="application/rss+xml" href="{RSS}"> 
    <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> 
    <script src="http://platform.twitter.com/anywhere.js?id=yQDKaggXesWYWPCPFNXn1Q&amp;v=1"> 
    </script> 
    <script type="text/javascript"> 
     twttr.anywhere(function(twitter) { 
      twitter.hovercards(); 
     }); 
    </script> 



</head> 
<body> 

    <div id="container"> 

     <div id="header"> 
      <ul> 
       <li><div id="logo"> 
        <h1 class="thecruecart">the crue cart 
        <img src="images/leaf.png" width="15" height="15" class="leaf"></h1> 
        <h1 class="wholesnackerie">whole snackerie<h1> 
       </div></li> 
       <!--Who What When Where Why Help!--> 
       <li class="navigation"><a href="home.html" class="navigation">Who<span class="green">?</span></a></li> 
       <li class="navigation"><a href="thewhat.html" class="navigation">What<span class="green">?</span></a></li> 
       <li class="navigation"><a href="thewhenwhere.html" class="navigation">When & Where<span class="green">?</span></a></li> 
       <li class="navigation"><a href="thewhy.html" class="navigation">Why<span class="green">?</span></a></li> 
       <li class="navigation"><a href="help.html" class="navigation">Help<span class="green">!</span></a></li> 
       <li class="navigation"><a href="order.html" class="navigation">ORDER<span class="green">!</span></a></li> 
       <li class="navigation"><div id="share"> 
       <iframe src="http://www.facebook.com/plugins/like.php?href=facebook.com%2Fthecruecart&amp;layout=button_count&amp;show_faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:75px; height:21px;" allowTransparency="true"></iframe> 
       <a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.twitter.com/thecruecart" data-text="Check out The Crue Cart!" data-count="horizontal">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> 
       </div></li> 
      </ul> 
     </div> 

     <div id="navbar"></div> 

     <div id="title"> 
      <h2 class="title">Catering? Hungry?</h2> 
     </div> 

     <div id="body"> 
      <p>The Crue Cart is a mobile bakery that finds its home in Bellevue. We love animals and nutrition, and our cupcakes show that.<br/> No wheat, no animal products (or by-products) and no processed sugar. Also, our products will be organic and locally produced<br/> whenever possible. We love supporting local agriculture and economy.</p> 
      <br/> 
      <p>Want to chat? <span class="chunky">Email us: [email protected]</span></p> 
     </div> 

     <div class="clearfooter"></div> 
    </div> 

    <div id="footer"> 
     <p class="ft">&copy the crue cart 2010. All Rights Reserved.</p> 
    </div>  
</body> 

CSS

@font-face { font-family: chunkfive; src: url("fonts/Chunkfive.otf") format("opentype"); }

 @font-face { 
    font-family: aller; 
    src: url("fonts/aller.ttf") format("truetype"); 
    } 

    @font-face { 
    font-family: tgheros; 
    src: url("fonts/tgheros.otf") format("opentype"); 
    } 

    @font-face { 
    font-family: tgheros-bold; 
    src: url("fonts/tgheros-bold.otf") format("opentype"); 
    } 

    html {} 

    body { 
      width:auto; 
      height:100%; 

      background-color:#ffffff; 
      margin:0px; 
      margin-left:auto; 
      margin-right:auto; 
      padding:0px; 
    } 

    h1, h2, h3, h4, h5, h6 { 
     font-family:chunkfive; 
     color:#0000ff; 
     margin:0px; 
    } 

    h1 { 
     font-family:chunkfive; 
     color:#0000ff; 
     font-size:30px; 
     margin:0px; 
     padding:0px; 
    } 

    h1.thecruecart { 
     font-family:chunkfive; 
     color:#0000ff; 
     font-size:30px; 
     margin-left:auto; 
    } 

    h1.wholesnackerie { 
     font-family:chunkfive; 
     color:#44aa00; 
     font-size:15px; 
     margin-left:40px; 
    } 

    h2.title { 
     font-size:35px; 
     margin-top:10px; 
     margin-left:10px; 
    } 

    h2 a{ 
     font-size:35px; 
     color:#44aa00; 
     margin-top:10px; 
     margin-left:10px; 
    } 

    img { 
     margin:0px; 
    } 

    img.leaf { 
     position:relative; 
     top:2px; 
     left:-8px; 
    } 

    p { 
     font-family:tgheros-bold; 
     font-size:18px; 
     color:#0000ff; 
     margin:0px; 
     margin-left:10px; 
    } 

    p.order{ 
     font-family:tgheros-bold; 
     font-size:16px; 
     color:#0000ff; 
     margin:0px; 
     margin-left:10px; 
    } 

    p.facebook { 
     display:inline; 
     font-family:tgheros-bold; 
     font-size:18px; 
     color:#0000ff; 
     margin:0px; 
     margin-left:5px; 
    } 

    p.ft { 
     color:#0000ff; 
     font-family:chunkfive; 
     font-size:14px; 
     letter-spacing:1px; 

     margin:0px; 
     padding:0px; 
    } 

    a { 
     color:#44aa00; 
     font-family:chunkfive; 
     font-size:20px; 
     letter-spacing:1px; 
     text-decoration:none; 
     margin:0px; 
     padding:0px; 
    } 

    a:link, a:visited, a:hover, a:active { 

    } 

    a.navigation { 
     color:#0000ff; 
     font-family:chunkfive; 
     font-size:20px; 
     text-decoration:none; 
    } 

    ul { 
     list-style-type:none; 
     margin:0px; 
     padding:0px; 
    } 

    li { 
     float:left; 
    } 

    li.navigation{ 
     display:inline; 
     position:relative; 
     top:33px; 
     float:left; 
     margin-left:45px; 
    } 

    iframe { 
     display:inline; 
     margin-top:0px; 
     margin-left:10px; 
    } 

    /*Facebook Stuffs*/ 

    /*Twitter Stuffs*/ 

    .chunky { 
     color:#44aa00; 
     font-family:chunkfive; 
     font-size:20px; 
     letter-spacing:1px; 
     margin:0px; 
     padding:0px; 
    } 

    .green { 
     color:#44aa00; 
    } 

    .clearfooter { 
     height:1px; 
     clear:both; 
    } 

    #container { 
     min-height:100%; 
     margin-bottom: -20px; 
     position: relative; 
    } 

    #header { 
     display:block; 
     width:auto; 
     height:58px; 
     padding-right:5px; 
     padding-left:5px; 
    } 

    #logo { 
     margin-top:0px; 
     margin-left:10px; 
    } 

    #navbar { 
     display:block; 
     width:auto; 
     height:2px; 
     background-color:#0000ff; 
    } 

    #share { 
     display:inline; 
     margin:0px; 
    } 

    #body { 
     width:1330px; 
     margin:0px; 
     margin-bottom:30px; 
     padding:0px; 
    } 

    #footer { 
     display:block; 
     width:auto; 
     height:10px;    
     position:realtive;   
     text-align:center; 
     clear:both; 
    }</code> 

回答

1

Problem is, is that you don't have a fixed width container you have width:100%, the site is liquid.

You need to set a width on a container and it will play nice!

0

You have set the body width to 1330px. If you are really making a site for a client, you might be better of going with the "standard" maximum width of 960px. That way the site will work properly on most screen sizes.

Some reading that sides the magic number: http://cameronmoll.com/archives/2009/04/is_it_time_to_move_beyond_960/

ps. You should not set the width to the body element itself, some older browsers are quite quirky with it, I think at least IE6 does not understand it, but cannot check now since I'm don't have it close to hand.

0

I don't think you have posted all the CSS styles in your question. Nevertheless, you have to fix the width of the navigation bar element in css. You could use a fixed width for your header div, but I'd use another div or ul for the navigation items and use fixed width on those, so that the rest of the items in the header can still float around.

0

You don't have a doctype and are in quirks mode. Add this to your first line and see where we stand: <!doctype html>

0

有造型的導航不少辦法,我對您的佈局的變化來說明如何你可能會接近它。

請參閱我的變化:http://jsfiddle.net/audetwebdesign/YzrUn/以及我的以下評論和解釋。

CSS樣式

您可以利用CSS選擇器,擺脫不必要的類,從而簡化您的樣式表。

將徽標作爲單獨的div保留在header中,並使用ul列表標記您的導航鏈接。

您可以排版您的標誌或使用圖像。固定logo div有助於一點,高度可以設置爲auto或者如果您使用的是圖片,則可以修復。

讓我們將徽標div浮動到左側,看看如何實現這一切。

將藍色邊框添加到header以充當可視分隔符。

的靈活的導航欄

設置「UL」名單的邊緣,使其清除標誌股利。由於徽標左側爲 ,所以需要左邊距,否則鏈接將覆蓋徽標。

我們將li元素浮動到左側,添加一些邊距,然後將a導航鏈接顯示爲block's,添加一些填充。

請注意我如何使用b添加綠色標點符號,比span + class更簡單。

最後,在最後一個li元素中添加一個類,以便您有一個鉤子來設置iframe和其他與社交媒體網站相關的位的樣式。

如何工作

在我的演示中,你可以改變輸出窗口的寬度。

當您縮小窗口時,鏈接(包括社交媒體位)將環繞到徽標的右側,並且標題面板將垂直展開,從而允許所有鏈接可在較小的屏幕上訪問或喜歡使用窄瀏覽器窗口的人。

這樣您就不必修復頁面的寬度,除非您有其他原因這樣做。

您可以調整各種元素的填充以獲得所需的垂直對齊。我認爲這裏有足夠的可調元素來照顧設計中的任何可能性。

最後,爲了獲得最佳效果,使用嚴格的文檔類型,否則,IE中的怪癖模式可能會導致問題。