2013-02-28 24 views
0

我想弄清楚如何編寫一些我以前沒見過的奇特佈局的CSS。下面的圖片包含部分。用於指導:奇特的CSS佈局問題

  • 第「1」是一個標題,即應該是固定的alpha區內
  • 第「2」是一個div,其應該有一個滾動條時,它得到太高(由所確定的視窗/窗口的高度)
  • 部分「3」是頁腳,應該在alpha區域內固定
  • 部分「4」是一個右手,流體容器,將有一個iframe。 iframe本身將管理滾動。

有什麼想法?

enter image description here

我此刻的代碼是那種所有的地方,但是這是我多麼接近了要點:

CSS: 
.controller { 
    width: 400px; 
    height: 100%; 
} 
.controller header { 
    position: absolute; 
    top: 0; 
    left: 0; 
    height: 60px; 
    width: 400px; 
} 
.controller footer { 
    position: absolute; 
    bottom: 0; 
    left: 0; 
    height: 60px; 
    width: 400px; 
} 
.controller .body { 
    overflow: scroll; 
} 
.focus { 
    float: left; 
    width: 100%; 
} 

Markup: 

<div class="wrapper"> 
    <div class="container"> 
     <header></header> 
     <div class="body"> 
     <footer></footer> 
    </div> 
    <div class="focus"> 
    </div> 
</div> 
+0

爲什麼你認爲它是奇特的? – Buzz 2013-02-28 04:12:13

+0

當然,這很容易。但是請先嚐試在Google上閱讀某些內容,然後當您嘗試時遇到問題時,請在此處詢問。 – 2013-02-28 04:12:46

+0

更新了我的問題。 – onassar 2013-02-28 04:14:07

回答

1

這裏是如何實現這一demo in jsFiddle

我使用的風格是

body, html { 
    padding:0; 
    margin:0; 
} 
.container { 
    width: 25%; 
    height: 100%; 
    float:left; 
    position:absolute; 
} 
.container header { 
    display:block; 
    height: 10%; 
    width:100%; 
    background-color:#ff5; 
} 
.container .body { 
    position: relative; 
    overflow: auto; 
    width: 100%; 
    height:80%; 
    background-color:#f5f; 
} 
.container footer { 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    height: 10%; 
    width: 25%; 
    background-color:#5ff; 
} 
.focus { 
    background-color:#ddd; 
    position: fixed; 
    left: 25%; 
    width:75%; 
    height: 100%; 
    overflow:auto; 
} 
.focus iframe{ 
    width:99%; 
    height: 99%; 
} 

希望這對你有所幫助。

+0

啊,這是非常感謝森雅各布。你知道是否有可能爲頁眉和頁腳使用精確的高度(例如60px高度),並且仍能達到預期效果? – onassar 2013-02-28 15:34:51

+1

我不確定,我也會嘗試。順便說一句,你可以爲此編寫腳本,或使用[LessCss](http://www.lesscss.org/)或[Sass](http://sass-lang.com/docs/yardoc/)進行復雜的ccs操作。 – 2013-03-01 13:07:20

+0

目前我正在使用SASS,但由於高度取決於訪問者的視口,我不確定我是否可以使用CSS(除了使用'calc' css方法) – onassar 2013-03-02 00:00:10