我认为这与
有没有可能使flex容器的子元素不像flex项一样呈现?例如: http://jsbin.com/jusehedumi/edit?html,css,output 是否有任何方法可以让第三个子元素表现得像一个普通的块元素?而不会因为父flex容器的
一个纯CSS的解决方案将是很棒的。思考一下,添加一些额外的HTML可能会使这个问题更容易修复/可解决。
< p > 编辑:我知道可以使用
display:flex
属性的工作方式完全相反,但我想知道是否可能,或者是否有一种hack方法。有没有可能使flex容器的子元素不像flex项一样呈现?例如: http://jsbin.com/jusehedumi/edit?html,css,output 是否有任何方法可以让第三个子元素表现得像一个普通的块元素?而不会因为父flex容器的
justicity-content:center
而自动对齐?一个纯CSS的解决方案将是很棒的。思考一下,添加一些额外的HTML可能会使这个问题更容易修复/可解决。
.flex{
display: flex;
justify-content: center;
width: 400px;
height: 400px;
background: #ccc;
}
.child{
width: 100px;
height: 100px;
background: red;
margin: 20px;
}
.child.three{
background: blue;
display: block;
}
Is there any way to make child three not behave as a flex child?
<div class="flex">
<div class="child one"></div>
<div class="child two"></div>
<div class="child three"></div>
</div>
position: absolute
或类似方法将子元素从flex容器中移出。我要找的是一种让其中一个子元素保持作为flex容器的子元素,同时表现为块级元素
(或内联元素
)的方法。