Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.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 为什么静态元素会移动?_Html_Css_Css Position - Fatal编程技术网

Html 为什么静态元素会移动?

Html 为什么静态元素会移动?,html,css,css-position,Html,Css,Css Position,如果静态定位的元素不受“顶部”、“底部”、“左侧”和“右侧”属性的影响,为什么在更改长方体元素的“边距顶部”值时长方体会随容器一起移动 我将代码保存在: HTML: 页边距在您发布的JSFIDLE中折叠: 添加溢出:自动/隐藏到.container或使用我在名为.no collapse的类中添加的以下css: .no-collapse:before { content: ""; display: table; } @静态默认定位不是吗?嗯,我的错。。。。我把注意力放错了。你能详

如果静态定位的元素不受“顶部”、“底部”、“左侧”和“右侧”属性的影响,为什么在更改长方体元素的“边距顶部”值时长方体会随容器一起移动

我将代码保存在:

HTML:


页边距在您发布的JSFIDLE中折叠:

添加溢出:自动/隐藏到.container或使用我在名为.no collapse的类中添加的以下css:

.no-collapse:before {
    content: "";
    display: table;
}

@静态默认定位不是吗?嗯,我的错。。。。我把注意力放错了。你能详细说明一下吗?页边空白处!=顶部…检查这个:我需要了解什么是collpased边距。我是css的初学者。这是我有时会遇到的问题>,只是更新了上面的答案,使之成为我在JSFIDLE中测试后发现的代码。它们不需要对.container或.boxEdit:进行任何更改。containerEdit:似乎在仍然移动之前使用。containerEdit:更新了代码一些指向主css的链接?
.container
{
    width:500px;
    height: 500px;
    background-color: grey;
    margin-top: 00px;
}

.box
{
    width:100px;
    height: 100px;
    background-color: orange;
    margin-top: 100px;

}
.no-collapse:before {
    content: "";
    display: table;
}