Reputation: 1404
I want to create sticky bottom toolbar that always stays at the bottom. It always should be visible on a screen. I tried to use position: fixed, bottom: 0
which definitely helped, but it overlaps my content. Here is how it overlaps (look at the bottom of the page):
Yes, I understand that it should overlap, but the problem is that I cannot scroll to bottom to see remaining text.
Here is my code:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
margin: 0;
padding: 0;
}
.bottom-toolbar {
position: fixed;
bottom: 0;
width: 100%;
background-color: yellow;
}
</style>
</head>
<body>
<div class="container">
<div class="article">
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
</div>
<div class="bottom-toolbar">
<p> My toolbar </p>
</div>
</div>
</body>
</html>
How can I solve this problem?
Upvotes: 2
Views: 814
Reputation: 659
position: fixed; always relative to viewport or, you can also use margin bottom to .article or padding-bottom: 60px (or your fotter-bar height) to .container.
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
margin: 0;
padding: 0;
}
.bottom-toolbar {
position: fixed;
bottom: 0;
width: 100%;
background-color: yellow;
}
.article {
margin-bottom: 60px;
}
</style>
</head>
<body>
<div class="container">
<div class="article">
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
<p>Lorem ipsum... Lorem....(a lot of text here)</p>
</div>
<div class="bottom-toolbar">
<p> My toolbar </p>
</div>
</div>
</body>
</html>
Upvotes: 1
Reputation: 3012
The footer is on top of the layer with the article text, so you can solve it by "making room" with some padding:
.article {
padding-bottom: 40px;
}
40px;
is just enough in a codepen, but add however much you want.
Upvotes: 2