Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.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
Css 左边距和左边距给出了相同百分比的不同值_Css_Css Position_Margin - Fatal编程技术网

Css 左边距和左边距给出了相同百分比的不同值

Css 左边距和左边距给出了相同百分比的不同值,css,css-position,margin,Css,Css Position,Margin,我有一个部门: width:100%; max-width:100%; position:relative; overflow:hidden; 该部门的直系子女是: .my-class { position:absolute; bottom:6px; padding-left:12px; } 我想让child div与其他内容对齐。除此之外,没有任何东西会影响它。当我使用left:30%时,我得到一个数字,当我使用margin left:3

我有一个部门:

 width:100%;
 max-width:100%;
 position:relative;
 overflow:hidden;
该部门的直系子女是:

 .my-class {

      position:absolute;
      bottom:6px;
      padding-left:12px;

 }
我想让child div与其他内容对齐。除此之外,没有任何东西会影响它。当我使用
left:30%
时,我得到一个数字,当我使用
margin left:30%
时,我得到一个不同的数字(在这种情况下,这就是我想要的)

左边距是否考虑了填充,左边距是否考虑了填充


或者还有其他我没有考虑的因素吗?

是的。
填充会影响边距。

看看这个例子:

div,span{
边框:1px实心#000;
高度:80px;
宽度:80px;
}
.左,.marginLeft{
背景:#aaf;
利润率:10px 0 10px;
填充:10px;
位置:相对位置;
}
.腹肌{
背景:#美国联邦航空局;
位置:绝对位置;
排名:0;
}
.左.腹肌{
左:100px;
}
.marginLeft.abs{
左边距:100px;
}
左
父母亲
左边
左边距
父母亲
左边距

jsfiddle就好了……这两个结果对我来说都一样-。