Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在Firefox上使用框大小填充更改div的大小_Html_Css_Firefox_Width_Padding - Fatal编程技术网

Html 在Firefox上使用框大小填充更改div的大小

Html 在Firefox上使用框大小填充更改div的大小,html,css,firefox,width,padding,Html,Css,Firefox,Width,Padding,我正在尝试向DIV中的元素添加填充。我的问题是它会将此填充添加到DIV的总大小中 我尝试使用div中的以下代码停止此操作: box-sizing: border-box; ms-box-sizing: border-box; webkit-box-sizing: border-box; moz-box-sizing: border-box; 它在Chrome上运行良好,但在Firefox上仍然存在问题。我不明白为什么 有人知道如何解决这个问题吗 非常感谢如果您想为div的宽度添加额外的填充:

我正在尝试向DIV中的元素添加填充。我的问题是它会将此填充添加到DIV的总大小中

我尝试使用div中的以下代码停止此操作:

box-sizing: border-box;
ms-box-sizing: border-box;
webkit-box-sizing: border-box;
moz-box-sizing: border-box;
它在Chrome上运行良好,但在Firefox上仍然存在问题。我不明白为什么

有人知道如何解决这个问题吗


非常感谢

如果您想为div的宽度添加额外的填充:

div {
    // In this example total div width is 120px
    // box-sizing: content-box is the default style. No need to specify it.
    width: 100px
    padding: 0 10px;
}
或者,如果要使填充部分成为总div宽度的一部分:

div { 
    // In this example total div width is 100px
    // support Firefox, WebKit, Opera and IE8+
    -moz-box-sizing: border-box;
    box-sizing: border-box; //always place the standard declaration last, so it overwrites browser specific ones in case they get deprecated  
    width: 100px
    padding: 0 10px;
}

请添加一个或代码..在
moz
和所有其他前缀之前缺少一个连字符,例如
-moz-box-size:border-box如果Adrift的评论无法修复,您使用的是什么版本的firefox?Adrift,非常感谢,它工作正常!此外,IE不需要
-ms-
前缀;它知道的唯一版本是普通的
框大小调整