2015-12-04 109 views
-2

我不是很擅長用文字描述這個問題,所以我畫了一個佈局應該具有的屬性的小圖片。如何實現這種CSS佈局?

enter image description here

我嘗試了幾種可能性,但我沒能實現這個沒有絕對定位和flexboxes。我對css hacks也不是很熟悉。

有沒有人有這種類型的佈局與CSS只有和IE9 +(如果可能的話IE8)兼容性的解決方案?

在此先感謝

+0

哪裏是你的代碼?你有什麼嘗試?你遇到什麼問題? – Shaggy

+2

創建此佈局有許多可能性,但是您需要向我們展示您嘗試的內容。我們不是免費的代碼寫作服務。 – j08691

回答

1

這裏是我的解決辦法,運氣好兄弟,歡迎到前端的世界。

Solution Here

HTML:

<body> 
    <div class="wrapper"> 
     <div id="header"></div> 
     <div id = "content"> 
      <div class="sidenav"></div> 
      <div class="info"></div> 
     </div> 
     <div id="footer"></div> 
    </div> 
</body> 

CSS:

body { 
    width: 100%; 
    height: 100%; 
    margin: 0; 
    padding: 0; 
} 

.wrapper { 
    min-height:100%; 
    position:relative; 
} 

#header { 
    position: fixed; 
    top: 0; 
    z-index: 9999; 
    padding-left: 0; 
    padding-right: 0; 
    width: 100%; 
    height: 4em; 
    background: navy; 
} 

#footer { 
    width: 100%; 
    height: 4em; 
    position: absolute; 
    bottom: 0; 
    left: 0; 
    background-color: pink; 
} 

#content { 
    width: 100%; 
    height: 2000px; 
    display: inline-block; 
    padding-top: 4em; /*same height header*/ 
    margin-top: 1em; 
    margin-bottom: 1em; 
    padding-bottom: 4em; 
    /* or: 
    padding: 4em 0 4em 0; 
    margin: 1em 0 1em 0; 
    */ 
} 

.sidenav { 
    float:left; 
    width:500px; 
    height: 100%; 
    background-color: gray; 
    margin-right: 1em; 
} 

.info { 
    overflow:hidden; 
    height: 100%; 
    background-color: purple; 
} 
1

這很簡單。

HTML

<header> 
</header> 

<section> 

    <aside> 
    </aside> 

    <article> 
    </article> 

</section> 

<footer> 
</footer> 

CSS

footer, 
header { 
    width: 100%; 
} 
section { 
    width: 100%; 
} 
section:after { 
    display: table; 
    content: ''; 
    clear: both; 
} 
aside { 
    width: 30%; 
    float: left; 
} 
article { 
    width: 60%; 
    float: right; 
} 

Here is an example

+0

謝謝你的時間和精力。我帶了Gilberto的anwser,因爲它在不指定寬度的情況下保持了靈活性,並且不使用表格進行對齊。 – Megamind