Bootstrap 4 align bottom [duplicate]

2020-01-19 06:09发布

I have a full-page bootstrap layout, and on the first page I need something aligned to middle & bottom. There is a background image (first div), and a darker layer on it (second div).

<div class="h-100 w-100">
<div class="h-100 w-100 text-center">
    <div class="h-100 w-100 d-flex align-items-center">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
            <h1 style="color:#000;">something</h1>  
            <a href="">
            www.something.com
            </a>
            <p class="tto_cl">
            <span style="font-size: 1.8rem;">123</span>
            </p>
            <span style="text-transform:uppercase; color:#000; letter-spacing: 4px; font-family: Arial;">456</span><br>
            </div>
    </div>
</div>

Jsfiddle: https://jsfiddle.net/543r2dcs/2/

They are aligned center perfectly, but I need something to bottom.

I want the 456 to the bottom of the div, but this new flexbox system is unusual to me.

3条回答
Ridiculous、
2楼-- · 2020-01-19 06:37

If you want it to be vertically centered, use my-auto margin y auto, which brings it to the center

查看更多
甜甜的少女心
3楼-- · 2020-01-19 06:37

Set the parent element position: relative then set the poisition for the element you want to be down the bottom to position: absolute then set its bottom to 0 bottom: 0 this will position it to the bottom of its parent container this might also break how you are centering the element so you will have to add left: 0 and right: 0

查看更多
啃猪蹄的小仙女
4楼-- · 2020-01-19 06:51

Bootstrap has a very handy .align-bottom class. You can read about it here

<span class="align-bottom">bottom</span>

查看更多
登录 后发表回答