2012-03-16 57 views
2

這是我第一次嘗試和設計/編碼一個網站,我學到了很多,迄今爲止,作爲我正在進行最後的調整,似乎無法糾正這最後一個問題。 理想情況下,側邊欄應位於最右側的固定位置,水平位置與左側的導航欄。目前,它位於左側標題/導航欄附近的主要內容之上。側邊欄問題 - 儘管位置:固定側邊欄不會留在它的地方..代碼和圖像包括

enter image description here

header { 
    background: none; 
    float: left; 
    margin-top: 123px; 
    margin-left: 22px; 
    position: fixed; 
    width: 158px; 
} 
#main { 
    float: left; 
    margin-left: 300px; 
    margin-top: 310px; 
} 
#sidebar { 
    border-top: 1px solid #202020; 
    float: right; 
    height: 100%; 
    margin-left: 252px; 
    margin-top: 295px; 
    padding-top: 25px; 
    position: fixed; 
    width: 158px; 
} 

    <header> 
     <div id="logo"> 
      <a href="#"><img src="img/logo.png" alt="whskytngfxtrt logo" height="139" width="158" /></a> 
     </div><!-- end logo --> 
     <nav> 
      <ul> 
       <li id="blog"><a href="#">BLOG</a></li> 
       <li id="work"><a href="#">WORK</a></li> 
       <li id="about"><a href="#">ABOUT</a></li> 
       <li id="contact"><a href="#">CONTACT</a></li> 
      </ul> 
     </nav><!-- end nav --> 
    </header><!-- end header --> 

    <div id="main"> 
     <article> 
      <h1><a href="#">Clever Headline</a></h1> 
      <h2 class="postinfo"> 
      <ul> 
       <li>Posted by <a href="#">Alex Chennault</a></li> 
       <li>1st March 2012</li> 
       <li>tags: <a href="#">cool</a>, <a href="#">awesome</a></li> 
      </ul> 
      </h2> 
      <p>One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment. His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. "What's happened to me? " he thought. It wasn't a dream. His room, a proper human room although a little too small, lay peacefully between its four familiar walls. A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer.</p> 
     </article><!-- end article --> 
    </div><!-- end main --> 

    <div id="sidebar"> 
     <section id="dictionary"> 
      <h3><b>hwis-kee tang-goh foks-trot</b></h3> 
      <h4><p><i>noun</i> 1. the best damn creative studio there ever was</p></h4> 
     </section><!-- end dictionary --> 

     <section id="twitter"> 
      <h3><a href="http://www.twitter.com/whskytngfxtrt">@whskytngfxtrt</a></h3> 
      <h4><ul> 
       <li><a href="#">sometimes i just really love the internet</a></li> 
       <li><a href="#">sometimes i just really love the internet</a></li> 
       <li><a href="#">sometimes i just really love the internet</a></li> 
      </ul></h4> 
     </section><!-- end twitter-feed --> 
    </div><!-- end sidebar --> 
+0

您的意思是說,您的導航菜單將在logo和分隔邊界線下對齊_horizo​​ntally_?如果不是,你是什麼意思? – Wex 2012-03-16 19:44:56

回答

0

你可能要調整幾件事情:

  1. 您要添加一些屬性到你的風格規則正在推動您的含量越低,即:

    margin-top: 295px; 
    padding-top: 25px; 
    

    您可能想要減少或消除這些。

  2. 你的位置設置爲fixed,但你不使用任何特定於它的設置位置的屬性,例如,topleft。您可以在這裏閱讀更多信息:http://reference.sitepoint.com/css/position

+0

通過推動我的內容降低意味着什麼?目前,我打算將它放在垂直軸上,我只需要它沿着水平軸推動。 另外,你可否詳細說明職位屬性?我已經嘗試了一下sitepoint提到的東西,但似乎沒有什麼區別於將頂部和左側值設置爲0的例外。 – AMC 2012-03-16 20:45:39