有没有办法利用Bootstrap 4随附的flexbox网格来创建砌体柱布局?在我看来,所有的列都是相等的高度。
这对于标准的Bootstrap 4类几乎是可行的。文档中甚至有一整节关于“证件栏”功能。
从文档中: 只需将CSS包裹在中,就可以使用CSS将 卡片组织成类似于砌体的列.card- columns
。卡是使用CSS
列属性而不是flexbox构建的,以便于对齐。卡的排列顺序是从上到下,从左到右。
小心! 您使用信用卡栏的里程可能会有所不同。为防止卡跨列断裂,我们必须将其设置display: inline-block
为column-break-inside: avoid
还不是防弹解决方案。
因此,您要做的就是将.card
s 包装到这样的.card-columns
容器中:
<div class="container">
<div class="card-columns">
<div class="card">
<img class="card-img-top" src="http://via.placeholder.com/1600x900/483D8B/ffffff?text=Card+1" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card title that wraps to a new line</h5>
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
</div>
<div class="card p-3">
<blockquote class="blockquote mb-0 card-body">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
<footer class="blockquote-footer">
<small class="text-muted">
Someone famous in <cite title="Source Title">Source Title</cite>
</small>
</footer>
</blockquote>
</div>
<div class="card">
<img class="card-img-top" src="http://via.placeholder.com/1600x450/9400D3/ffffff?text=Card+2" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
<div class="card bg-primary text-white text-center p-3">
<blockquote class="blockquote mb-0">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.</p>
<footer class="blockquote-footer">
<small>
Someone famous in <cite title="Source Title">Source Title</cite>
</small>
</footer>
</blockquote>
</div>
<div class="card text-center">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
<div class="card">
<img class="card-img" src="http://via.placeholder.com/1600x1600/FF1493/ffffff?text=Card+3" alt="Card image">
</div>
<div class="card p-3 text-right">
<blockquote class="blockquote mb-0">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
<footer class="blockquote-footer">
<small class="text-muted">
Someone famous in <cite title="Source Title">Source Title</cite>
</small>
</footer>
</blockquote>
</div>
<div class="card">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>
</div>
</div>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
问题内容: 我想在CSS中使用大小均相同但高度不相同的元素来实现网格效果。我希望下面的元素始终位于底部元素的50px处,无论接下来是什么。 我尝试使用浮点数,但该错误。因此,我尝试使用Flex,但是它仍然无法满足我的要求。 问题答案: Try the new CSS Grid Layout 建立一个块级网格容器。该grid-auto-rows属性设置自动生成的行的高度。在此网格中,每行高度为50p
问题内容: 我正在尝试仅使用CSS和flexbox创建水平砌体布局。我遇到的问题是元素之间存在垂直间隙,而没有使用它可以缩小间隙吗? 问题答案: 这是一个使用换行列的选项,但它需要固定的高度。
我想要一个3xN布局在我的移动React Native应用程序,所以像这样的东西: 整个布局,垂直的,将在滚动视图,这样即使它加载的项目超过一个屏幕可以显示,它可以正确地显示它的整体。
在 React Native 中使用 flexbox 规则来指定某个组件的子元素的布局。 flexbox 可以在不同屏幕尺寸上提供一致的布局结构。 一般来说,使用 flexDirection、alignItems 和 justifyContent 三个样式属性就已经能满足大多数布局需求。 React Native 中的 flexbox 的工作原理和 web 上的 css 基本一致,当然也有差异。首
主要内容:网格类,Bootstrap 4 网格的基本结构,Bootstrap4 网格基本结构,实例,实例,实例,平板和桌面端,实例,平板、桌面、大桌面显示器、超大桌面显示器,实例,偏移列,实例Bootstrap 提供了一套响应式、移动设备优先的流式网格系统,随着屏幕或视口(viewport)尺寸的增加,系统会自动分为最多 12 列。 我们也可以根据自己的需要,定义列数: 1 1 1 1 1 1 1 1 1 1 1 1 4 4 4 4 8 6 6 12 Bootstrap 4 的网格系统是响应式的
问题内容: 我是JS新手,希望这个问题看起来不太愚蠢。 我在我的网站上使用砖石结构- 效果很好。我想让我的盒子在砌筑完成时出现。在互联网上搜索时,我发现了几则建议使用图像加载的插件来解决此问题的帖子。它只是什么都没有改变。这意味着:我的布局和内容框一直被弄乱,直到砌筑完成加载为止,然后框突然跳到了正确的位置。 我的代码: 我也收到此萤火虫错误: 我在网站结尾处像这样加载了imagesloaded