Code simplification examples for CSS Common properties

Source: Internet
Author: User

CSS code simplification is very useful and necessary in the work. When writing CSS code, there is often redundant code, in order to improve the quality of the code and file compression to the minimum, so that the code is readable, have to simplify the CSS code. Here's an example of some of the more commonly used properties.

Margin

margin-top:1px;

margin-right:1px;

margin-bottom:1px;

margin-left:1px;

Code simplification to: margin:1px

margin-top:1px;

margin-right:2px;

margin-bottom:1px;

margin-left:2px;

Code simplification to: margin:1px2px

margin-top:1px;

margin-right:2px;

margin-bottom:3px;

margin-left:2px;

Code simplification to: margin:1px2px3px

margin-top:1px;

margin-right:2px;

margin-bottom:3px;

margin-left:4px;

Code simplification to: margin:1px2px3px4px

Note: When the property value is 0, the unit can not write as: 0px directly written 0

Padding

The writing method of padding is similar to margin

padding-top:1px;

padding-right:1px;

padding-bottom:1px;

padding-left:1px;

Code simplification to: padding:1px

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.