我试图<div>在CSS中设置一个特定的百分比高度,但它只是保持与其中的内容相同的大小.<!DOCTYTPE html>但是,当我删除HTML 5 时,它可以工作,根据<div>需要占用整个页面.我希望页面验证,所以我该怎么办?
我有这个CSS <div>,其ID为page:
#page {
padding: 10px;
background-color: white;
height: 90% !important;
}
Run Code Online (Sandbox Code Playgroud) 我知道我们可以calc在定义长度时使用:
flex-basis: calc(33.33% - 60px);
left: calc(50% - 25px);
height: calc(100em/5);
Run Code Online (Sandbox Code Playgroud)
但是如果长度是可变的呢?
height: calc(100% - <<header with variable height>>);
Run Code Online (Sandbox Code Playgroud)
要么
width: calc(100% - 50px - <<box with variable width>>);
Run Code Online (Sandbox Code Playgroud)
在CSS中有一种标准的方法吗?
我知道使用flexbox和表可以完成整个任务,但我想知道CSS是否提供了一种更简单的方法.Flexbox,表格和简单的Javascript是可接受的替代方案.