How to set padding in css: 1. Use the padding attribute to set all the padding of the element (top, right, bottom, left) in one statement; 2. Use padding-top, padding-bottom, padding- The left and padding-right properties set the top, bottom, left and right padding respectively.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
1. Use the padding attribute
padding is a shorthand attribute that can set all padding attributes in one statement. This attribute can have 1 to 4 values.
Example:
padding:10px 5px 15px 20px;
The top padding is 10px
The right padding is 5px
The bottom padding is 15px
The left padding is 20px
padding:10px 5px 15px;
The top padding is 10px
The right and left padding is 5px
The bottom padding is 15px
padding:10px 5px;
The top and bottom padding is 10px
The right and left padding is 5px
padding:10px;
All four paddings are 10px
2. Use padding-top, padding-bottom, padding-left, padding-right attributes
padding-top Set the top padding of the element
padding-bottom Set the bottom padding of the element
padding-left Set the left padding of the element
padding-right Set the right padding of the element
(Learning video sharing: css video tutorial)
The above is the detailed content of How to set padding in css. For more information, please follow other related articles on the PHP Chinese website!