如何强制一行及其cols使用其父元素(jumbotron)高度的100%

时间:2018-05-01 10:51:04

标签: html css twitter-bootstrap bootstrap-4

This is what I have and what I want

所以我想将标语垂直和水平对齐到jumbotron,顶部标识位于正确的位置,小型同种型应该一直在jumbotron的底座上。

非常感谢任何帮助。

#hero {
    height: 50vh;
    background-image: url("/img/background.png");
    background-size: cover;
    background-repeat: no-repeat;
    padding-top: 0.5em;
    padding-bottom: 0.5em;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4"
        crossorigin="anonymous">
    <link rel="stylesheet" href="/css/custom.css">
    <title>Document</title>
</head>

<body>
    <div class="jumbotron jumbotron-fluid" id="hero">
        <div class="container">
            <div class="row">
                <div class="col-12 text-left align-top h-25">
                    <img src="/img/toplogo.png" alt="">
                </div>
                <div class="col-12 text-center align-middle h-auto">
                    <img src="img/slogan.png" alt="">
                </div>
                <div class="col-12 text-right align-bottom test">
                    <img src="/img/logowhite.png" alt="">
                </div>
            </div>
        </div>
    </div>
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
        crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ"
        crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm"
        crossorigin="anonymous"></script>
</body>

</html>

2 个答案:

答案 0 :(得分:1)

如果我是正确的,你要求将标语垂直对齐中心,并将同种型对齐到底部,如上图所示。您可以在口号和小型同种型中添加以下内联样式部分。

将口号与中间对齐:

<img src="img/slogan.png" alt="" style="top:--height from the top-- ;">

<img src="img/slogan.png" alt="" style="display: flex; flex-direction: column; justify-content: center;">

将小同种型设置为底部:

<img src="/img/logowhite.png" alt="" style="top:--height from the top-- ;">

<img src="img/logowhite.png" alt="" style="display: flex; flex-direction: column; justify-content: center;">

我认为,这对您有用。

答案 1 :(得分:0)

用户@ZimSystem表示只需要在行和容器中添加h-100

感谢您的帮助。