CSS3 Calc () calculation Properties Detailed description

Source: Internet
Author: User
As its name, Calc is the new computed attribute in CSS3, which allows many attributes to add an expression to the argument;

Calc is an abbreviation for the English word Calculate (calculation) and is a new feature of CSS3, and you can use Calc () to set dynamic values for attributes such as border, margin, pading, font-size, width, and height of the element.

How to use

Calc () can use simple plus (+), minus (-), multiply (*), and divide (/) in math to solve problems, and can also convert calculations based on units such as Px,em,rem and percentages.
The standard notation:


  . class{/       *         area:expression;       *       /Width:calc ();       Padding:calc ();       Margin-top:calc ();       ...   }

Compatibility

Basic theory

    1. Calc can be used to set dynamic values for any property with size, such as border, margin, pading, font-size, and width.

    2. Supported operating units: REM, em, percentage, px

    3. Compute precedence and math consistency

Note the point:

Calc internal expression, when using the operation symbol, two times must add a space (although multiplication can be ignored, but it is recommended)!!!!! , or it will parse the error!! , look at the presentation.


    Width:calc (Ten * 10px);    Width:calc (50%-50px);    Width:calc (50% + 5em);    Width:calc (10%/1rem);

Small Demo

Just as a demonstration, responsive scaling

Code


<!     DOCTYPE html>

Summarize

Calac and Flexbox collocation, used to write flow layout is very good;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.