calc()函数
css3中函数:
- 用于动态计算长度值。(注意事项:运算符前后都需要保留一个空格,例如: calc(100% - 10px))
- 任何长度值都可以使用calc()函数进行计算;
- calc()函数支持 "+", "-", "*", "/" 运算;
- calc()函数使用标准的数学运算优先级规则
案例:
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <title></title> 6 <style> 7 .div1{ 15 width: calc(400px - 200px); 16 height: 200px; 17 background: red;; 18 } 19 </style> 20 </head> 21 <body> 22 <div class="div1"></div> 25 </body> 26 </html>