簡體   English   中英

浮動div,100%高度

[英]Floated div, 100% height

Ť 在此輸入圖像描述

***** {

    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    margin: 0;
    padding: 0;
    list-style: none;
}

#footer-gradient {

    position: relative;
    width: 100%;
    overflow: hidden;
    padding: 0 18px;
    margin-left: -18px;
    background: -moz-linear-gradient(top,  rgba(214,212,200,0.5) 0%, rgba(214,212,200,0.75) 25%, rgba(214,212,200,1) 50%, rgba(214,212,200,0.75) 75%, rgba(214,212,200,0.5) 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(214,212,200,0.5)), color-stop(25%,rgba(214,212,200,0.75)), color-stop(50%,rgba(214,212,200,1)), color-stop(75%,rgba(214,212,200,0.75)), color-stop(100%,rgba(214,212,200,0.5))); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top,  rgba(214,212,200,0.5) 0%,rgba(214,212,200,0.75) 25%,rgba(214,212,200,1) 50%,rgba(214,212,200,0.75) 75%,rgba(214,212,200,0.5) 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top,  rgba(214,212,200,0.5) 0%,rgba(214,212,200,0.75) 25%,rgba(214,212,200,1) 50%,rgba(214,212,200,0.75) 75%,rgba(214,212,200,0.5) 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top,  rgba(214,212,200,0.5) 0%,rgba(214,212,200,0.75) 25%,rgba(214,212,200,1) 50%,rgba(214,212,200,0.75) 75%,rgba(214,212,200,0.5) 100%); /* IE10+ */
    background: linear-gradient(to bottom,  rgba(214,212,200,0.5) 0%,rgba(214,212,200,0.75) 25%,rgba(214,212,200,1) 50%,rgba(214,212,200,0.75) 75%,rgba(214,212,200,0.5) 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#80d4d2c6', endColorstr='#80d4d2c6',GradientType=0 ); /* IE6-9 */
    -moz-box-shadow:    inset 0 0 98px #a9a798;
    -webkit-box-shadow: inset 0 0 98px #a9a798;
    box-shadow:         inset 0 0 98px #a9a798;

}

.col {

    margin-left: 0;
    float: left;
}

.col:first-child {

    margin-left: 0;
}

.footer {

    width: 33%;
    *width: expression(Math.floor(0.33 * (this.parentNode.offsetWidth - parseFloat(this.parentNode.currentStyle.paddingLeft) - parseFloat(this.parentNode.currentStyle.paddingRight))) + "px");
}

.footer-left {

    background-color: red;
    height: 100% !important;
    min-height: 100% !important;
}

.footer {

    background-color: red;
    height: 100% !important;
    min-height: 100% !important;
}

我想讓div.col拉伸到100%的高度。 我嘗試了很少的東西,但沒有一個能解決這個問題。 我指望你的幫助。

提前致謝 !

  1. 設置三個元素的容器( #footer-gradientdisplay: table
  2. 並設置元素本身( .coldisplay: table-cell
  3. 刪除浮動。
  4. 成功。

#footer-gradient {
    display: table;
}
#footer-gradient .col {
    display: table-cell;
    float: none;
}

像這樣

演示

CSS

    .footer{
   display:table;
    width:100%;
}
.col1{
    background-color:red;
    display:table-cell;
}
.col2{
    background-color:red;
    display:table-cell;
    padding:0 10px;
}
.col3{
    background-color:red;
    display:table-cell;
}

為什么不使用clear:both

<div id="footer-gradient">
   ...
   <div class="clear"></div>             <!---- Inside footer-gradient div. -->
</div>

CSS:

.clear{ clear:both; }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM