I think the easiest way to execute the layout using bootstrap is as follows:
<section> <div class="container"> <div class="row"> <div align="center"> <div style="max-width: 200px; background-color: blueviolet;"> <div> <h1 style="color: white;">Content goes here</h1> </div> </div> </div> </div> </div>
all I did was add div layers that allowed me to center the div, but since I don't use percentages, you need to specify the maximum div width for the center.
You can use the same method to center more than one column, you just need to add more div layers:
<div class="container"> <div class="row"> <div align="center"> <div style="max-width: 400px; background-color: blueviolet;"> <div class="col-md-12 col-sm-12 col-xs-12" style="background-color: blueviolet;"> <div class="col-md-8 col-sm-8 col-xs-12" style="background-color: darkcyan;"> <h1 style="color: white;">Some content</h1> </div> <div class="col-md-4 col-sm-4 col-xs-12" style="background-color: blue;"> <p style="color: white;">More content</p> </div> </div> </div> </div> </div> </div>
Note: I added a div with column 12 for md, sm and xs, if you do not, the first div with the background color (in this case "blueviolet") will crash, you can see the child divs, but not the background color.
TheOneAndOnly ME Jul 24 '17 at 15:55 2017-07-24 15:55
source share