gpt4 book ai didi

html - 对一个元素使用 "px"和 "%"

转载 作者:可可西里 更新时间:2023-11-01 12:53:56 25 4
gpt4 key购买 nike

是否有权对一个元素同时使用“px”和“%”

.box{
padding:10px 2% 0 3%;
}

这是在 css 中使用的权利吗?

最佳答案

CSS 2.1 specification for padding 中所述(强调我的)

The 'padding' property is a shorthand property for setting 'padding-top', 'padding-right', 'padding-bottom', and 'padding-left' at the same place in the style sheet.

If there is only one value, it applies to all sides. If there are two values, the top and bottom paddings are set to the first value and the right and left paddings are set to the second. If there are three values, the top is set to the first value, the left and right are set to the second, and the bottom is set to the third. If there are four values, they apply to the top, right, bottom, and left, respectively.

所以 padding: 10px 2% 0 3%; 等价于

padding-top: 10px;
padding-right: 2%;
padding-bottom: 0;
padding-left: 3%;

这是完全有效的 CSS。

玩得开心!

关于html - 对一个元素使用 "px"和 "%",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2949119/

25 4 0
文章推荐: javascript - 表单仍然在 JS 中回发并返回 false
文章推荐: php - SOAP - 加载本地 WSDL 文件
文章推荐: html - 如何让我的文本在具有较大边框半径的
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com