How to set padding in css

青灯夜游
Release: 2021-04-29 15:35:00
Original
12369 people have browsed it

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.

How to set padding in css

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;
Copy after login
  • The top padding is 10px

  • The right padding is 5px

  • The bottom padding is 15px

  • The left padding is 20px

padding:10px 5px 15px;
Copy after login
  • The top padding is 10px

  • The right and left padding is 5px

  • The bottom padding is 15px

padding:10px 5px;
Copy after login
  • The top and bottom padding is 10px

  • The right and left padding is 5px

padding:10px;
Copy after login
  • 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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template