Home >Web Front-end >CSS Tutorial >Examples of abbreviations for margin, padding, border, background and font under CSS_Experience exchange

Examples of abbreviations for margin, padding, border, background and font under CSS_Experience exchange

WBOY
WBOYOriginal
2016-05-16 12:05:341720browse

Below are examples of some of the more commonly used attributes.

margin

margin-top:1px;
margin-right:1px;
margin-bottom:1px;
margin-left:1px;
Code Simplified to: margin:1px

margin-top:1px;
margin-right:2px;
margin-bottom:1px;
margin-left:2px;
Code simplification For: margin:1px 2px

margin-top:1px;
margin-right:2px;
margin-bottom:3px;
margin-left:2px;
Code simplification For: margin:1px 2px 3px

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

Note: When the attribute value is 0, the unit does not need to be written, such as: 0px directly written as 0

padding

Padding The writing method is similar to margin

padding-top:1px;
padding-right:1px;
padding-bottom:1px;
padding-left:1px;
Code simplification For: padding:1px

padding-top:1px;
padding-right:2px;
padding-bottom:1px;
padding-left:2px;
The code is simplified to :padding:1px 2px

padding-top:1px;
padding-right:2px;
padding-bottom:3px;
padding-left:2px;
The code is simplified to :padding:1px 2px 3px

padding-top:1px;
padding-right:2px;
padding-bottom:3px;
padding-left:4px;
Code simplification For: padding:1px 2px 3px 4px

border

border-width:1px;
border-style:solid;
border-color:#000000;
Code Simplified to: border:1px solid #000

background

background-color:#CCFFFF;
background-image:url(picture path);
background-repeat:repeat -x;
background-position:5px 4px;
The code is simplified to: background:#CFF url (image path) repeat-x 5px 4px

font

font-size :26px;
font-weight:bold;
font-family: "宋体";
The code is simplified to: font:26px bold "宋体"

color attribute value
Color: #000000;
Color: #ff0000;
The code is simplified to: color: #000, color: #f00

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn