我想知道如何证明在justify-content: space-between中允许使用flexbox多少空间。
目前,我的项目是间隔的,但它们之间的空间太大了,我希望它们之间只有一点空间,这样它们就可以放置在中间的某处。
下面的代码片段有望澄清我正在努力解决的问题。
如果你需要我进一步澄清,请告诉我。谢谢!
#qwrapper {
display: flex;
height: 100%;
width: 100%;
align-items: center;
justify-content: center;
}
.row {
flex: 0 auto;
height: 100px;
margin: 0;
}
#lighticon {
padding-bottom: 30px;
}
@media (max-width: 800px) {
#qwrapper {
flex-direction: column;
align-items: center;
}
}
@media screen and (max-width: 480px) {
#qwrapper {
flex-wrap: wrap;
}
.row {}
}
@media only screen and (min-width: 760px) {
#qwrapper {
justify-content: space-between;
margin: 10px;
}
#lighticon {
position: relative;
margin-left: 100px;
}
}<div id="qwrapper">
<h3 id="michelle" class="row">"She always thinks of her clients."
<br>
</h3>
<img src="https://cdn4.iconfinder.com/data/icons/black-icon-social-media/512/099310-feedburner-logo.png" class="row" alt="" id="lighticon" />
<h3 id="jerry" class="row">"Very smart, creative person, problem solver."
<br>
</h3>
</div>
发布于 2019-03-01 04:13:01
我发现自己在所有的框中都添加了右边距(在本例中是三个)
.three {
margin-right: 2%
}然后去掉它,这样最后一个盒子就对齐了
.three:nth-child(3) {
margin-right: 0%;
}但每次我这样做的时候,我都在想“一定有更好的方法,一些烘焙到flex-box中的东西……这是可行的,但它看起来像是一种变通方法?”
发布于 2019-03-27 16:24:14
如果您想使用space-between,使用边距的方法并不是通用的解决方案,因为它会在所有可变元素上设置边距,也会在一行或列的第一个和最后一个元素上设置边距。当设置了flex-wrap: wrap时,使用:first-child / :last-child/ :nth-child()选择器不会有什么帮助,因为您永远无法分辨换行或换行列上哪些元素是第一个元素和最后一个元素。
像:wrapped这样的选择器会很有帮助,但遗憾的是它并不存在。
所以我的结论是,当你真的想释放flexbox的灵活性和响应性时,你不能控制…的边际我要说的是错过了这个规范的机会。
发布于 2019-08-24 15:13:08
下面的组合对我很有效。(最初由@T04435提到)
justify-content: space-around; flex-items: margin-left;
https://stackoverflow.com/questions/42080123
复制相似问题