Quite new here, I'll try my best to explain. I'm trying to do a one page bootstrap application with several <div>
and a nav bar on the very top of the page. I'd like that <div>
fill the height of browser window, with text in the center of that div.
My problems
- the text won't center
- if I remove the outer wrapper
<div id="welcome" class="welcome">
and put the css on"container fill-height"
, the whole section becomes in the middle but not full screen wide. I have no idea why we need two wrappers for that<div class="textWelcome"><h2>welcome to first div</h2></div>
.
Below is my code with comments to further explain the question. Thanks in advance for your help!
<div id="welcome" class="welcome"> // when user scroll to this div, it fills the screen under nev bar
<div class="container fill-height">
<div class="textWelcome">
<h2> Welcome to first div </h2> //this text should be in the middle of the "welcome" div
</div>
</div>
</div>
This is my current CSS which does not work:
.welcome{
padding-top: 150px;
padding-bottom: 150px;
background: #E41b13;
}
.textWelcome{
vertical-align: middle;
font-family: 'Georgia';
color: rgb(255, 255, 255); /*white text*/
font-weight: bold
}
Update: Now everything seems ok except that text is not vertically centered
<div class="container fill-height">
<div class="row">
<div class="col-lg-1"></div>
<div id="hello" class="col-lg-10">
<h1 style="text-align:center;"> Hello World</h1>
</div>
<div class="col-lg-1"></div>
</div>
</div>
and CSS:
.fill-height{
padding-top: 150px;
padding-bottom: 150px;
background: #E41b13;
min-height: 100%;
height:100vh;
}
#hello{
vertical-align: middle;
font-family: 'Georgia';
color: rgb(255, 255, 255); /*white text*/
font-weight: bold
}