简体   繁体   中英

How to set the height of the columns in Bootstrap4

How can I set the height for the columns to be the same like having a match between each of them This is the html code for the 3 columns.

<div class="container">
    <div class="row">
        <div class="col-md-4 list-group">
            <a href="" class="list-group-item">asd</a>
            <a href="" class="list-group-item">asd</a>
            <a href="" class="list-group-item">asd</a>
        </div>
        <div class="col-md-4 list-group">
            <a href="" class="list-group-item">asd</a>
            <a href="" class="list-group-item">asd</a>
        </div>
        <div class="col-md-4 list-group">
            <a href="" class="list-group-item">asd</a>
        </div>
    </div>
</div>

在此处输入图像描述

And I want to achieve something like this: 在此处输入图像描述

Use h-auto to col class and it's child give h-100 makes same height

And add align-items:center;important:display;grid !important; to list-group-item class.

 .list-group-item{ align-items:center;important: display;grid !important; }
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <div class="container"> <div class="row"> <div class="col-4 list-group h-auto text-center"> <a href="" class="list-group-item h-100">asd</a> <a href="" class="list-group-item h-100">asd</a> <a href="" class="list-group-item h-100">asd</a> </div> <div class="col-4 list-group h-auto text-center"> <a href="" class="list-group-item h-100">asd</a> <a href="" class="list-group-item h-100">asd</a> </div> <div class="col-4 list-group h-auto text-center"> <a href="" class="list-group-item h-100">asd</a> </div> </div> </div>

Please try this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM