This time to bring you CSS3 of the Calc () method How to use, CSS3 of the Calc () method used to note what, the following is the actual case, together to see.
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.
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
Redraw and rearrange how to use
How to use CSS settings to record user passwords