css 背景图片完全填充
Remember margins? Recall how margin is the space around an element which gives you the comfortable or compact feel and look on a webpage. Margin clears the area outside the border of an element. Padding is similar to margin, but not the same. Confused? Read on.
还记得边距吗? 回想一下元素周围的空白量如何,可以为您带来舒适或紧凑的感觉和外观。 边距清除元素边界之外的区域。 填充与边距相似,但不相同。 困惑? 继续阅读。
Padding clears the area inside the border of the element. It introduces extra space between the boundary and the content of the element. Just like the margin property, padding
has a shorthand property that sets the padding for all the four sides. It can also be set individually.
填充清除元素边框内的区域。 它在边界和元素内容之间引入了额外的空间。 就像margin属性一样, padding
有一个简写属性,用于设置所有四个边的padding。 也可以单独设置。
Syntax:
句法:
padding: value1 [value2 value3 value4] | inherit
Where each padding value is either a length, percentage value, auto, or inherit from the parent element.
其中每个填充值是length , percent value , auto或从父元素继承 。
A padding of 40px, padding:40px;
means an extra space of 40px
will be added around the content of the element on all the sides.
填充40px, padding:40px;
表示将在所有侧面的元素内容周围添加40px
的额外空间。
Here is a video to explain all about padding
property.
这是一段视频,解释有关padding
属性的所有内容。
Video Transcript:
影片字幕:
The overall behaviour of padding
property is similar to margin
property, the one major difference between the margin and the padding property is that unlike margin, padding cannot take negative values.
padding
属性的整体行为类似于margin
属性,margin和padding属性之间的主要区别在于,与margin不同,padding不能取负值。
Elements may have default padding on them and these values may vary. If you want to reset all paddings to zero and then add your own values, you can use a wildcard rule like *{ padding: 0; }
to clear all paddings.
元素可能具有默认填充,并且这些值可能会有所不同。 如果要将所有填充都重置为零,然后添加自己的值,则可以使用通配符规则,例如*{ padding: 0; }
*{ padding: 0; }
清除所有垫衬。
This is compatible with CSS1, CSS2 and CSS3 along with following Web Browsers,
它与CSS1 , CSS2和CSS3以及以下Web浏览器兼容,
IE 4+
IE 4+
Firefox 1+
Firefox 1+
Opera 3.5+
Opera 3.5+
Safari 1+
Safari 1+
Chrome 1+
Chrome1+
That was all about padding. Now you must be thinking, what next? Well next up, we will learn how to position elements on a webpage.
这就是关于填充。 现在您必须在思考,下一步呢? 接下来,我们将学习如何在网页上放置元素。
翻译自: https://www.studytonight.com/cascading-style-sheet/css-padding
css 背景图片完全填充