logo

该视频仅会员有权观看

立即开通课程「Web前端页面基础」权限。

¥
199
/ 年

CSS 容器样式(background, margin, padding, border)

Summary

To set a background for an element with the ID app, you can use the background style property for either a background image or a simple background color like #69f0ae. To solely set the background color, background-color can be used. By default, browsers add an 8-pixel margin around elements, which can be overridden in the style sheet by setting the margin property to zero, removing the margin around the element. Margin can also be individually adjusted using properties like margin-left and margin-right. A single value given to margin will apply uniformly to all four sides of the element.

Internal spacing within the element, known as padding, can be set similarly to margin using properties like padding-left, padding-right, or a single padding value for uniform padding on all sides. Adding a border to the bottom of the element can be done using properties like border-bottom-width, border-bottom-style, and border-bottom-color, or with the shorthand border-bottom property which combines width, style, and color. You can also set a uniform border on all sides using the border property.>margin can also be used to add uniform external spacing. In the browser, the computed styles panel will show the content width and height, padding, border, and margin of the element.