我真的很喜欢 CSS 的 box-sizing 属性。在 Chrome、IE8+ 和 Opera(不知道从哪个版本开始)支持此功能。Firefox 4 似乎忽略了它。
我知道有 -moz-box-sizing 属性,但是每次我想更改 box-sizing 类型时,我真的必须编写它吗?
代码
<html>
<head>
<style type="text/css">
.outer{
width:600px;
height:100px;
background-color:#00ff00;
border:1px solid #000;
}
.inner{
width:100%;
height:100%;
background-color:#ff0000;
border:1px solid #fff;
box-sizing:border-box;
}
</style>
</head>
<body>
<div class="outer">
<div class="inner"></div>
</div>
</body>
</html>