我已经开始使用flex,并且喜欢它的工作方式。
我正在使用flex布局,我希望在
我想要实现的是在两个按钮之间添加空间,但我不想使用右侧或左侧的margin。我希望
除了在按钮周围添加margin/padding以外,还有没有更好的方法来实现相同的效果?
谢谢。
以下是代码:
我正在使用flex布局,我希望在
dashboard-body
中使用btn-group
类时,它可以完全覆盖父元素的宽度。现在,它的宽度等于两个按钮的宽度之和。我想要实现的是在两个按钮之间添加空间,但我不想使用右侧或左侧的margin。我希望
btn-group
div可以拥有其父元素dashboard-body
的全部宽度,这样我就可以使用flex属性align-content: space-between
来在两个按钮之间留出足够的空间。除了在按钮周围添加margin/padding以外,还有没有更好的方法来实现相同的效果?
谢谢。
以下是代码:
.dashboard-body {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
flex-direction: column;
}
<div class="dashboard-body">
<p>You don't have any sales data.</p>
<p>Please add a new book or upload CSVs.</p>
<div class="btn-group">
<a href="#">
<input class="add-new-book-btn" type="submit" value="Add New Book">
</a>
<a href="#">
<input class="add-new-book-btn" type="submit" value="Upload CSV">
</a>
</div>
.btn-group { align-self:stretch; }
。https://jsfiddle.net/bLaoh9td/ - pawelalign-content: space-between
在这种情况下不起作用。有什么解决方法吗? - vikrantnegi.btn-group
也变成一个 flex 容器:https://jsfiddle.net/bLaoh9td/1/ (顺便说一下,应该是justify-content
)。 - pawel