gpt4 book ai didi

javascript - 设置宽度和填充 : ensure that the width includes/compensates for padding

转载 作者:太空宇宙 更新时间:2023-11-04 15:21:56 24 4
gpt4 key购买 nike

在 CSS 中,当我将元素宽度设置为 100px 然后将其填充设置为 10px,它的实际宽度为 120px。

注意:我不确定这种情况是一直发生还是仅在 position = absolute 时发生,就像我的所有元素一样。

是否有一个设置,如果我告诉一个元素宽度为 100 像素(并且填充为 10 像素),它的宽度将始终为 100 像素?有没有办法确保宽度补偿填充?

myClass { width: 100px; padding: 10px; }

最佳答案

有:

box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;

关于javascript - 设置宽度和填充 : ensure that the width includes/compensates for padding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7976456/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com