在CSS中,我该怎么做这样的事情:
width: 100% - 100px;
Run Code Online (Sandbox Code Playgroud)
我想这很简单但是很难找到显示出来的例子.
Cha*_*had 249
现代浏览器现在支持:
width: calc(100% - 100px);
Run Code Online (Sandbox Code Playgroud)
要查看支持的浏览器版本checkout列表:我可以使用calc()作为CSS单位值吗?
有一个jQuery回退:css width:calc(100%-100px); 使用jquery的替代方案
Ari*_*yck 98
你能不能嵌套一个div margin-left: 50px;和margin-right: 50px;内<div>用width: 100%;?
bar*_*acı 16
你可以尝试这个......
<!--First Solution-->
width: calc(100% - 100px);
<!--Second Solution-->
width: calc(100vh - 100px);Run Code Online (Sandbox Code Playgroud)
vw:视口宽度
vh:视口高度
小智 7
只有当我检查了所有空格后,它才开始对我起作用。所以,它不是这样工作的:width: calc(100%- 20px)orcalc(100%-20px)并与 完美配合width: calc(100% - 20px)。
我的代码,它适用于 IE6:
<style>
#container {margin:0 auto; width:100%;}
#header { height:100px; background:#9c6; margin-bottom:5px;}
#mainContent { height:500px; margin-bottom:5px;}
#sidebar { float:left; width:100px; height:500px; background:#cf9;}
#content { margin-left:100px; height:500px; background:#ffa;}
</style>
<div id="container">
<div id="header">header</div>
<div id="mainContent">
<div id="sidebar">left</div>
<div id="content">right 100% - 100px</div>
<span style="display:none"></span></div>
</div>
Run Code Online (Sandbox Code Playgroud)
