Abbreviations commonly used in CSS

Source: Internet
Author: User

Using abbreviations can help reduce the size of your CSS files and make it easier to read. The main rules for CSS abbreviations are as follows:

Color

16 color value, if the value of each two digits is the same, you can abbreviate half, for example: #000000可以缩写为 #000; #336699可以缩写为 #369; #f2f2f2是不可以缩写的

Border of the box model

border-width:1px;

Border-style:solid;

Border-color: #000;

can be abbreviated as a sentence:

border:1px solid #000;

Grammar is border:width style color;

Border and padding of the box model

margin-top:1px; margin-right:2px; margin-bottom:3px; margin-left:4px;

margin:1px 2px 3px 4px;

Note: The order here is clockwise, respectively: upper right and lower left

MARGIN:1PX 2px;

margin:0;

Note: CSS in the value of 0 can be without units, other times must be with units

Background

Background-color: #f00;

Background-image:url (background.gif);

Background-repeat:no-repeat;

background-attachment:fixed;

background-position:0 0;

can be abbreviated as a sentence:

Background: #f00 URL (background.gif) no-repeat fixed 0 0;

Font

Font-style:italic;

Font-variant:small-caps;

Font-weight:bold;

Font-size:1em;

line-height:140%;

font-family: "Lucida Grande", Sans-serif;

can be abbreviated as a sentence:

Font:italic small-caps Bold 1em/140% "Lucida Grande", Sans-serif;

Note that if you abbreviate a font definition, you must define at least two values for font-size and font-family.

List

List-style-type:square;

List-style-position:inside;

List-style-image:url (Image.gif);

can be abbreviated as a sentence:

List-style:square inside URL (image.gif);

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.