Bootstrap 4:对齐卡片组内的内容

2024-02-02

我的 Bootstrap 4 页面中有一副纸牌。我想对齐这些按钮以获得更好的外观。我们怎样才能做到这一点?

Here is an image: Screenshot

这是演示:http://7freres.com/new http://7freres.com/new

这张桌子似乎不起作用,因为它们是分开的。

Thanls


你可以使所有card-text元素具有相同的高度。 一种方法是通过 JavaScript。写一个这样的函数:

document.addEventListener("DOMContentLoaded", function(event) { 
    adjustCardTextHeights();
});

function adjustCardTextHeights() {
    var heights = $(".card-text").map(function() {
        return $(this).height();
    }).get();

    maxHeight = Math.max.apply(null, heights);

    $(".card-text").height(maxHeight);
}

或者使用 jQuery:

$( document ).ready(function() {
    adjustCardTextHeights();
});

function adjustCardTextHeights() {
    var heights = $(".card-text").map(function() {
        return $(this).height();
    }).get();

    maxHeight = Math.max.apply(null, heights);

    $(".card-text").height(maxHeight);
}

This gets you: enter image description here

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Bootstrap 4:对齐卡片组内的内容 的相关文章

随机推荐