how to center a div horizontally and vertically in bootstrap 4 code example

Example 1: bootstrap center text vertically

<div class=”row”>
	<div class=”col-6 align-self-center”>
    	<div class=”card card-block”>
    		Center
        </div>
    </div>
</div>

Example 2: how to center a div vertically and horizontally

.container{	
	margin: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    -ms-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
  	width: /* Define the width here; */
    height: /* Define the height here; */
}

/*You have to define the width and height! */

Tags:

Css Example