左邊隨右邊高度變化

有時須要左邊高度隨右邊進行變化,用height:100%,是不可行的,由於須要父級進行高度設定css

使用左邊絕對定位,top:0;bottom:0;能夠實現blog

<div class="con">
    <div class="con-left"></div>
    <div class="con-right">1111111</div>
</div>

  css以下:it

.con{
    position: relative;
    padding-left: 50%;
}
.con-left{
    width: 40%;
    background: #007aff;
    position: absolute;
    top:0;
    bottom: 0;
    left: 0;
}
.con-right{
    width: 60%;
    padding: 10% 0;
}
相關文章
相關標籤/搜索