参考大漠的文章:
CSS3的calc()使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.demo {
width: 300px;
background: #60f;
padding: 3px 0;
}
.box {
width: 90%; /* 给不支持calc()函数的浏览器设置了固定宽度 参考:https://www.w3cplus.com/css3/how-to-use-css3-calc-function.html 不支持ie6 - 8*/
width: calc(100% - (10px + 5px) * 2);
background: #f60;
height: 50px;
padding: 10px;
border: 5px solid green;
}
</style>
</head>
<body>
<div class="demo">
<div class="box"></div>
</div>
</body>
</html>