Reputation: 2305
I have a page with a sticky navbar at the top, and I gave the navbar a height 50px, and pushed the body using padding-top of 50px but now the page has a scrollbar. How can I get rid of the scrollbar?
Here is HTML:
<body>
<div class="container">
<!-- Navigation bar section -->
<nav class="navbar-fixed-top" role="navigation">
<div class="navbar-header"> <a class="navbar-brand" href="#">Project name</a>
</div>
<div class="navbar-collapse">
<ul class="navbar-nav">
<li><a href="#">Tutorials</a>
</li>
<li><a href="#">About</a>
</li>
</ul>
</div>
</nav>
</div>
<!--/.container-->
</body>
and the CSS:
* {
margin: 0;
}
html, body {
height: 100%;
}
body {
padding-top: 50px;
}
/* top navigation bar
* ------------------ */
.navbar-fixed-top {
top: 0px;
position: fixed;
right: 0px;
left: 0px;
z-index: 1030;
min-height: 50px;
margin-bottom: 20px;
border: 1px solid black;
background: white;
display: block;
clear: both;
}
.navbar-header {
float: left;
padding: 15px;
background-color: lightblue;
clear: both;
}
.navbar-brand {
font-size: 18px;
line-height: 20px;
}
.navbar-collapse {
float: left;
background-color: #FF9933;
}
.navbar-nav {
}
.navbar-nav > li {
float: left;
display: block;
}
.navbar-nav > li > a {
line-height: 20px;
position: relative;
display: block;
padding: 15px;
}
Upvotes: 2
Views: 195
Reputation: 439
Pushing the body pushes everything that the window displays (the document). I don't recommend it.
Making a div called space and setting it's height to 50px would fix it: so...
The css:
.space {
height: 50px;
width: 100%;
}
The Html:
<div class="space"></div>
Then you can use it more than once. Put the div after the navigation.
Upvotes: 0
Reputation: 38252
Use the property box-sizing
box-sizing:border-box
To make the value of the padding be included inside the value of the height
.
Upvotes: 2