相关疑难解决方法(0)

为什么div是"display:table-cell;" 不受保证金影响?

我有div彼此相邻的元素display: table-cell;.

我想margin在它们之间设置,但margin: 5px没有效果.为什么?

我的代码:

<div style="display: table-cell; margin: 5px; background-color: red;">1</div>
<div style="display: table-cell; margin: 5px; background-color: green;">1</div>
Run Code Online (Sandbox Code Playgroud)

html css

206
推荐指数
3
解决办法
16万
查看次数

确切地说,"margin:0 auto"需要什么?上班?

我知道margin: 0 auto;元素上的设置用于居中(左 - 右).但是,我知道元素及其父元素必须满足某些标准才能使自动边距起作用,而我似乎永远无法获得正确的魔力.

所以我的问题很简单:必须在元素及其父元素上设置什么CSS属性才能让margin: 0 auto;孩子左右中心?

css

191
推荐指数
4
解决办法
11万
查看次数

css绝对位置不适用于margin-left:auto margin-right:auto

假设您将以下css应用于div标签

.divtagABS {
    position: absolute;
    margin-left: auto;  
    margin-right:auto;
 }
Run Code Online (Sandbox Code Playgroud)

margin-left和margin-right不生效

但如果你有亲戚,那就行了

,divtagREL {
position: relative;
margin-left: auto;  
 margin-right:auto;
}
Run Code Online (Sandbox Code Playgroud)

这是为什么?我只是想要一个元素

有人可以解释为什么在绝对位置设置自动保证金不起作用吗?

html css html5 position css3

71
推荐指数
4
解决办法
10万
查看次数

标签 统计

css ×3

html ×2

css3 ×1

html5 ×1

position ×1