This article mainly introduced the detailed CSS 3 of the Calc () method, very good, with reference value, the need for friends can refer to, hope to help everyone.
The following snippet shows you The Calc () method in CSS3, as follows:
<p style= "width:100px; height:50px; background:red; " > <p style= "width:100%; height:20px; margin:5px; background:green;" ></p></p>
[Ctrl + A All SELECT prompt: You can modify some of the code, and then press run]
As the code above, the preview can see that the red box is out of bounds, because in standard CSS, width is not a margin (the width of old IE contains margin).
In order to achieve the above effect, we will generally be in the middle of another layer of P (some people say, not to take the width:100% to take it?) Calmly, we are for example, in some cases, can not cancel width:100%. )
Is there any more convenient? Use Calc ().
<p style= "width:100px; height:50px; background:red; " > <p style= "Width:calc (100%-10px); height:20px; margin:5px; background:green;" ></p></p>
[Ctrl + A All SELECT prompt: You can modify some of the code, and then press run]
Instructions for use
Support: + 、-、 *,/, support mixed
Support:%, px, EM, REM, etc.
+,-must have a space before and after, for example: Calc (100%-10px) is not correct, should be replaced by: Calc (100%-10px)
*,/front and back can not be space, but suggested there.
Support of
Mainstream desktop browsers are supported. Mobile browsers are said to have little support.