Calc () and CSS3calc () in CSS3 ()

Source: Internet
Author: User

Calc () and CSS3calc () in CSS3 ()
What is calc ()?

Calc is the abbreviation of the English word calculate (calculation). It is a new feature of css3;

MDN can be used in any length, value, time, angle, frequency, etc;

/* Property: calc (expression) */width: calc (100%-80px );

You can use the +-*/symbol to perform operations;

Note that +-must be separated by spaces;

Width: calc (100%-8px);/* an error occurs, and the result is 0 */
Width: calc (100%-8px);/* When the +-symbol is separated by a space, the operation is successful */

When using the */operator, you must ensure that there is a value of the numerical type;

If an operation error occurs, the result is 0;

Browser support:

IE9 +, FF4.0 +, Chrome19 +, Safari6 +;

Some small examples:

It can also be used in combination

You can also use parentheses to increase the computing priority.

Calc () is still relatively useful. For example, if you want to center an absolute positioning element, it is usually left: 50%; top: 50%; but is it true that it is centered? This method does not include the width and height of the element. Using calc () can center the element previously implemented by js.

Below are some references:

Https://developer.mozilla.org/en/docs/Web/CSS/calc

Http://www.w3cplus.com/css3/how-to-use-css3-calc-function.html

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.