css - 你知道为什么只出现3张牌吗?

标签 css twitter-bootstrap

我正在使用 bootstrap,我想连续放置 4 张卡片,每张卡片占据相同的宽度。但是下面的代码不起作用。只有 3 张卡片出现。看来问题是因为每张卡之间有很多余量。你知道如何正确解决这个问题吗?

示例:http://jsfiddle.net/h82w46Lz/1/

HTML::

<div class="container mt-4">
    <div class="row">
        <div class="col mb-4">
            <div class="card" style="width: 18rem;">
                <img class="card-img-top" src="https://via.placeholder.com/286x180" alt="Card image cap">
                <div class="card-body">
                    <h5 class="card-title">Card title</h5>
                    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-outline-primary">Read</a>
                </div>
            </div>
        </div>
        <div class="col mb-4">
            <div class="card" style="width: 18rem;">
                <img class="card-img-top" src="https://via.placeholder.com/286x180" alt="Card image cap">
                <div class="card-body">
                    <h5 class="card-title">Card title</h5>
                    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-outline-primary">Read</a>
                </div>
            </div>
        </div>
        <div class="col mb-4">
            <div class="card" style="width: 18rem;">
                <img class="card-img-top" src="https://via.placeholder.com/286x180" alt="Card image cap">
                <div class="card-body">
                    <h5 class="card-title">Card title</h5>
                    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-outline-primary">Read</a>
                </div>
            </div>
        </div>
        <div class="col mb-4">
            <div class="card" style="width: 18rem;">
                <img class="card-img-top" src="https://via.placeholder.com/286x180" alt="Card image cap">
                <div class="card-body">
                    <h5 class="card-title">Card title</h5>
                    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-outline-primary">Read</a>
                </div>
            </div>
        </div>
        <div class="col mb-4">
            <div class="card" style="width: 18rem;">
                <img class="card-img-top" src="https://via.placeholder.com/286x180" alt="Card image cap">
                <div class="card-body">
                    <h5 class="card-title">Card title</h5>
                    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-outline-primary">Read</a>
                </div>
            </div>
        </div>
        <div class="col mb-4">
            <div class="card" style="width: 18rem;">
                <img class="card-img-top" src="https://via.placeholder.com/286x180" alt="Card image cap">
                <div class="card-body">
                    <h5 class="card-title">Card title</h5>
                    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-outline-primary">Read</a>
                </div>
            </div>
        </div>
        <div class="col mb-4">
            <div class="card" style="width: 18rem;">
                <img class="card-img-top" src="https://via.placeholder.com/286x180" alt="Card image cap">
                <div class="card-body">
                    <h5 class="card-title">Card title</h5>
                    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-outline-primary">Read</a>
                </div>
            </div>
        </div>
        <div class="col mb-4">
            <div class="card" style="width: 18rem;">
                <img class="card-img-top" src="https://via.placeholder.com/286x180" alt="Card image cap">
                <div class="card-body">
                    <h5 class="card-title">Card title</h5>
                    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-outline-primary">Read</a>
                </div>
            </div>
        </div>
    </div>
</div>

最佳答案

关闭前四张卡片的行 div 并添加“col-lg-3”类而不是“col”,并对后四张卡片执行相同的操作。

关于css - 你知道为什么只出现3张牌吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53402794/

相关文章:

jquery - 如何防止 li 中的溢出文本将右浮动文本推错位置?

javascript - 无法更改背景颜色

javascript - Jquery - 滚动到底部在 Bootstrap 模式中不起作用

jquery - Bootstrap navbar-fixed-top 隐藏页面内容

html - 如何制作响应式条纹

html - Bootstrap container 或者 Well keep the well one size and enlarge text

html - 如何使 div 宽度仅适合其内容,下一个 div 填充其余部分?

css - 如何使用CSS设置背景图片宽度?

javascript - 如何将自动尺寸图像元素紧紧包裹在容器中?

javascript - 将复杂类型传递给 Bootstrap 模式