[英]How to make full div without using width and height property?
我有一個代碼
<div class="outer">
<div class="inner">A</div>
</div>
我的外部對窗口大小有響應,即寬度= 100%,高度= 100%。
我需要的是將“內部”作為100%的高度和寬度,但不使用內部的寬度和高度屬性?
i.e inner{height: 100%; width : 100%}
即使我不想使用js?
.outer{
position:relative;
}
.inner{
position:absolute;
left:0;
top:0;
right:0;
bottom:0;
}
我們可以做position
屬性
.outer{
position:relative;
}
鏈接: http : //www.w3schools.com/css/css_positioning.asp了解這一點
你可以嘗試下面的代碼:
<div class="outer" style="width:100%;height:100%">
<div class="inner" style="display: block;height: inherit;">A</div>
</div>
訪問此網址:
http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks
它使用float元素作為輸出。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.