I am using bootstrap 3 to design a HTML page and right now I am facing a problem. I want my div tag container to take 100% height of the browser window but using CSS only (no javascript).
I went through lots of questions in stack overflow itself but couldn't find a solution that could help me. I don't want to use vh, as when you resize your window it wont work properly or wont show the container properly and I have 5 div tag containers and want every container to be the same size of the browser window.
p.s I don't think html or css is required as it can be answered without the code.
-
1Really? this shows up as the first result if you look for "make a div take all of the screen" and it seems to work just fineRemysc– Remysc2016年05月24日 08:43:51 +00:00Commented May 24, 2016 at 8:43
-
3Possible duplicate of Make div 100% height of browser windowMarcus– Marcus2016年05月24日 08:45:57 +00:00Commented May 24, 2016 at 8:45
-
@Remysc i have div which contains 5 more divs and i want every of those div to fit the browser window and i also have a margin of 15 px both on bottom and top.Ramin Daqiq– Ramin Daqiq2016年05月24日 09:07:04 +00:00Commented May 24, 2016 at 9:07
3 Answers 3
Is this what you want?
html, body {
height: 100%;
margin: 0;
}
#thediv{
min-height:100%;
min-width:100%;
background-color:red;
display:flex;
align-items:stretch;
position:relative;
}
.interiordiv{
background-color:blue;
width:50px;
margin:15px auto 15px auto;
}
<div id="thediv">
<div class="interiordiv">A</div>
<div class="interiordiv">V</div>
<div class="interiordiv">C</div>
<div class="interiordiv">D</div>
<div class="interiordiv">E</div>
</div>
If not please try to make it clearer, if you don't want to post code that's ok but post a mockup image or something.
5 Comments
All that is required is to set the 'min-height' CSS attribute of the Div you wish to re-size:
<div style="min-height: 100%"></div>
Ensure your html & body tags have a height of 100% also.
Comments
Here you go.. as you said you are using bootstrap, you might override the row class and achieve this easily.
.row{
height:100%;
}
<div class="row bg-success"></div>
<div class="row bg-danger"></div>
<div class="row bg-warning"></div>
<div class="row bg-info"></div>
<div class="row bg-primary"></div>
Here are the screen sizes I tested it with.
enter image description here enter image description here THESE TWO WERE FULL SCREEN DESKTOPS
enter image description here enter image description here THESE WERE NON-FULL SCREEN BROWSER
enter image description here enter image description here THESE WERE IPHONE RESOLUTION IN PORTRAIT MODE
enter image description here enter image description here THESE WERE IPHONE RESOLUTION IN LANDSCAPE MODE