I've got a bootstrap jumbotron on a website, and I was wondering how I would make it the full width and height of the screen, or at least touching the nav bar, as there is a gap between the jumbotron and the navbar.
So far, I have a "container" class inside the "jumbotron" class to make it full width of the screen without rounded corners, but how would I have it so it would be the full width and height of the device's window until someone scrolls down?
So far this is what I've got:
<div class="jumbotron"> <div class="container"> <center><h1>Hello, World!</h1> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ligula mauris, iaculis quis tortor eget, ultricies mollis nisi. </p> <a class="btn btn-default" href="#">Button 1</a> <!-- <a class="btn btn-info" href="#">Button 2</a> --> </center> </div> </div>
To make the jumbotron full width, and without rounded corners, add the . jumbotron-fluid modifier class and add a . container or . container-fluid within.
We can add a background image to the jumbotron using the CSS style sheet. Use . background-image : url("image_address") within the stylesheet. Here is an example to add a background image to the jumbotron.
You can change your . jumbotron height using @media() queries to reflect major screen sizes. At some point, you will overflow the image but at least it won't be by much because you have established that the . jumbotron won't go too far from the 2:1 ratio.
So we have 3 issues here:
The default bootstrap navbar has a margin-bottom: 20px
, you want to override that like this:
.navbar { margin-bottom: 0px; }
Bootstrap's documentation says:
To make the jumbotron full width, and without rounded corners, place it outside all .containers and instead add a .container within.
So basically:
<div class="jumbotron"> <div class="container"> ... </div> </div>
I'm not sure how cleanly this will fit into your project, but you can try something like:
.jumbotron{ height: 100vh; }
*A good-to-know: The vh
stands for viewport height
You can achieve this by using the jumbotron just beneath the navbar. You should use the jumbotron inside a container or div, with its class as:
<div class="container-full-bg">
Using 'full-bg' will increase the width of jumbotron to fit the page. In order to increase the height, I used the text within the container class or simply used <br>
tags to increase the jumbotron height accordingly per my needs. A sample:
<div class="container-full-bg"> <!-- increased the jumbotron width --> <div class="jumbotron "> <div class="container"> <br><br><br> <p> Write here <p> <br><br><br><br> </div> </div> </div>
Now to display the image properly in the jumbotron, use background-size as cover,customizing the css file as:
.jumbotron{ background-image: url(show-copy.jpg) ; background-size: cover; height: 100%; width: 100%; }
Hope this helps :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With