Make Bootstrap 4 use 100% of screen height

1

<div class="container h-100">
<div class="row justify-content-center">
    <div class="col-4 my-auto">
        <div class="card">
            <div class="card-header">
                <div class="row">
                    <div class="col-2">
                        <img src="http://s1134.photobucket.com/user/PW_PrimeiroChefe/media/Kratos.png.html"style="height: 30px; width: 30px;" alt="Logo da Empresa">
                    </div>
                    <div class="col-10">
                        <h5 class="card-title">Login</h5>
                        <h6 class="card-subtitle">nome da empresa</h6>
                    </div>
                </div>
            </div>
            <div class="card-body">
                <form>
                    <div class="form-group">
                        <label for="exampleInputEmail1">Usuário</label>
                        <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
                    </div>
                    <div class="form-group">
                        <label for="exampleInputPassword1">Senha</label>
                        <input type="password" class="form-control" id="exampleInputPassword1">
                    </div>
                    <button type="submit" class="btn btn-primary">Entrar</button>
                </form>
            </div>
        </div>
    </div>
</div>

    
asked by anonymous 14.02.2018 / 13:10

1 answer

3

Set the html, body in CSS to have the height of the viewport :

html, body{
   height: 100%;
}

Then put the class h-100 also in .row :

<div class="row justify-content-center h-100">

Example:

html, body{
   height: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<div class="container h-100">
<div class="row justify-content-center h-100">
    <div class="col-4 my-auto">
        <div class="card">
            <div class="card-header">
                <div class="row">
                    <div class="col-2">
                        <img src="http://s1134.photobucket.com/user/PW_PrimeiroChefe/media/Kratos.png.html"style="height: 30px; width: 30px;" alt="Logo da Empresa">
                    </div>
                    <div class="col-10">
                        <h5 class="card-title">Login</h5>
                        <h6 class="card-subtitle">nome da empresa</h6>
                    </div>
                </div>
            </div>
            <div class="card-body">
                <form>
                    <div class="form-group">
                        <label for="exampleInputEmail1">Usuário</label>
                        <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
                    </div>
                    <div class="form-group">
                        <label for="exampleInputPassword1">Senha</label>
                        <input type="password" class="form-control" id="exampleInputPassword1">
                    </div>
                    <button type="submit" class="btn btn-primary">Entrar</button>
                </form>
            </div>
        </div>
    </div>
</div>
    
14.02.2018 / 14:39