Reputation: 77
I`m trying to make a webpage with a sticky footer, however when the content of the body is long enough, the footer overlaps the content. Could you tell me please how to fix this? I already tried about 5 different "sticky footer" scripts, but every single one doesn't work.
Thank you!
https://jsfiddle.net/za9jzdf6/
html {
position: relative;
min-height: 100%;
}
body {
margin: 0 0 170px; /* bottom = footer height */
background-color: #FFFFFF;
min-height: 100%;
}
footer {
padding-top: 20px;
padding-bottom: 0px;
background-color: #5D9CFF;
position: absolute;
left: 0;
bottom: 0;
height: 170px;
width: 100%;
text-align: center;
background-color: #4a80b0;
background-image: url("http://www.transparenttextures.com/patterns/navy.png");
}
header {
position: relative;
background-image:url(http://s6.postimg.org/3osi1wfld/starmenu.png);
margin: 0 auto;
height: 299px;;
width: 893px;
z-index:: 1000;
}
menu {
position: relative;
top: 40px;
}
#contentbg {
height: 100%;
background-color: #F3F3F3;
margin: 0 auto;
min-height: 100%;
text-align: center;
}
#paypal {
text-align: center;
margin: 0 auto;
}
#contentmain{
margin: 0 auto;
text-align: center;
min-height: 100%;
}
#headerwrap {
margin: 0 auto;
height: 254px;
background-color: #bd4617;
background-image: url("http://www.transparenttextures.com/patterns/dark-stripes-light.png");
}
.nl {
text-decoration:none;
}
h2 {
color: #055DBB;
font-style: italic;
font-weight: 400;
letter-spacing: -1px;
line-height: 1.1em;
text-align: center;
font-size: 30px;
font-family: "Myriad Web Pro", Palatino, "Palatino Linotype", "Times New Roman", "Times Italic";
}
h3 {
color: #232323;
font-style: normal;
font-weight: 400;
letter-spacing: -1px;
line-height: 1.1em;
text-align: center;
font-size: 22px;
font-family: "Myriad Web Pro", Palatino, "Palatino Linotype", "Times New Roman", "Times Italic";
}
h4 {
font
color:#FFFFFF;
text-align: center;
font-size: 16px;
font-family: Calibri;
color: #FFFFFF;
font-weight: 300;
font-style: normal;
font-variant: small-caps;
}
h10 {
text-align: center;
color: #055DBB;
font-style: normal;
font-weight: 400;
letter-spacing: -1px;
line-height: 1.1em;
text-align: center;
font-size: 30px;
font-family: "Myriad Web Pro", Palatino, "Palatino Linotype", "Times New Roman", "Times Italic";
}
h12 {
text-align: center;
color: #000000;
font-style: normal;
font-size: 20px;
font-family: "Myriad Web Pro", Palatino, "Palatino Linotype", "Times New Roman", "Times Italic";
font-weight: bold;
}
h13 {
text-align: center;
color: #000000;
font-style: normal;
font-size: 20px;
font-family: "Myriad Web Pro", Palatino, "Palatino Linotype", "Times New Roman", "Times Italic";
font-weight: normal;
}
h14 {
text-align: center;
color: #006CFF;
font-style: normal;
font-size: 20px;
font-family: "Myriad Web Pro", Palatino, "Palatino Linotype", "Times New Roman", "Times Italic";
font-weight: bold;
}
a.header:link {
color: #000000;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;
font-size: 22px;
text-decoration: none;
font-style: normal;
font-weight: bold;
font-variant: small-caps;
}
a.header:visited {
color: #000000;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;
font-size: 22px;
text-decoration: none;
font-style: normal;
font-weight: bold;
font-variant: small-caps;
}
a.header:hover {
color: #0069CC;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;
font-size: 22px;
text-decoration: none;
font-style: normal;
font-weight: bold;
font-variant: small-caps;
}
a.header:active {
color: #000000;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;
font-size: 22px;
text-decoration: none;
font-style: normal;
font-weight: bold;
font-variant: small-caps;
}
#menu {
margin-left: 33px;
position: absolute;
top: 165px;
}
.row a {
margin: 0 20px 0 4px;
}
.row a:nth-child(3) {
margin-left: 310px;
}
.row a:nth-child(2) {
margin-left: 12px;
}
.row a:nth-child(1) {
margin-left: 20px;
}
<body>
<div id = "headerwrap">
<header>
<div class="row" id="menu">
<a href="latestindexv1.html" class="header">Home</a>
<a href="coinmarket.html" class="header">Coin Market</a>
<a href="autobuyer.html" class="header">Autobuyer</a>
<a href="contact.html" class="header">Contact </a>
</div>
</header>
</headerwrap>
<div id = "contentmain">
<br><br>
<br><br>
<h13>
<p>text</p>
<p>text</p>
<p>text</p>
</h13>
<div id="form">
<iframe src="https://docs.google.com/forms/d/1aEWswORyYcfzLGW6sCEYN3IKY75rXoxYG7750ikMbjI/viewform?embedded=true" width="560" height="950" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>
</div>
</div>
<footer>
<a href="http://www.skype.com" class="nl" target="blank" title="skype">
<img src="images/footer_icons/skype_off.png" width="40" height="40" onmouseover="this.src='images/footer_icons/skype_on.png'" onmouseout="this.src='images/footer_icons/skype_off.png'" border="0" />
</a>
<a href="http://www.skype.com" class="nl" target="blank" title="youtube">
<img src="images/footer_icons/youtube_off.png" width="40" height="40" onmouseover="this.src='images/footer_icons/youtube_on.png'" onmouseout="this.src='images/footer_icons/youtube_off.png'" border="0" />
</a>
<a href="WEBSITE URL HERE" class="nl" target="blank" title="email">
<img src="images/footer_icons/mail_off.png" width="40" height="40" onmouseover="this.src='images/footer_icons/mail_on.png'" onmouseout="this.src='images/footer_icons/mail_off.png'" border="0" />
</a>
<a href="WEBSITE URL HERE" class="nl" target="blank" title="viber">
<img src="images/footer_icons/viber_off.png" width="40" height="40" onmouseover="this.src='images/footer_icons/viber_on.png'" onmouseout="this.src='images/footer_icons/viber_off.png'" border="0" />
</a>
<h4>All copyrights belong to their respective owners.
<br><br>
2015 ⚽ SamArt Studio</h4>
</footer>
</body>
Upvotes: 1
Views: 96
Reputation: 28593
Change your position to relative and i've added an extra div between the content between the content and the footer - a 'push' div Output
html {
position: relative;
min-height: 100%;
}
body {
margin: 0 0 170px;
/* bottom = footer height */
background-color: #FFFFFF;
min-height: 100%;
}
#push {
height: 170px;
}
footer {
padding-top: 20px;
padding-bottom: 0px;
background-color: #5D9CFF;
position: relative;
left: 0;
bottom: 0;
height: 170px;
width: 100%;
text-align: center;
background-color: #4a80b0;
background-image: url("http://www.transparenttextures.com/patterns/navy.png");
}
header {
position: relative;
background-image: url(http://s6.postimg.org/3osi1wfld/starmenu.png);
margin: 0 auto;
height: 299px;
;
width: 893px;
z-index: : 1000;
}
menu {
position: relative;
top: 40px;
}
#contentbg {
height: 100%;
background-color: #F3F3F3;
margin: 0 auto;
min-height: 100%;
text-align: center;
}
#paypal {
text-align: center;
margin: 0 auto;
}
#contentmain {
margin-top: 0;
margin-left: auto;
margin-right: auto;
margin-bottom: -170px;
text-align: center;
min-height: 100%;
position: relative;
}
#headerwrap {
margin: 0 auto;
height: 254px;
background-color: #bd4617;
background-image: url("http://www.transparenttextures.com/patterns/dark-stripes-light.png");
}
.nl {
text-decoration: none;
}
h2 {
color: #055DBB;
font-style: italic;
font-weight: 400;
letter-spacing: -1px;
line-height: 1.1em;
text-align: center;
font-size: 30px;
font-family: "Myriad Web Pro", Palatino, "Palatino Linotype", "Times New Roman", "Times Italic";
}
h3 {
color: #232323;
font-style: normal;
font-weight: 400;
letter-spacing: -1px;
line-height: 1.1em;
text-align: center;
font-size: 22px;
font-family: "Myriad Web Pro", Palatino, "Palatino Linotype", "Times New Roman", "Times Italic";
}
h4 {
font color: #FFFFFF;
text-align: center;
font-size: 16px;
font-family: Calibri;
color: #FFFFFF;
font-weight: 300;
font-style: normal;
font-variant: small-caps;
}
h10 {
text-align: center;
color: #055DBB;
font-style: normal;
font-weight: 400;
letter-spacing: -1px;
line-height: 1.1em;
text-align: center;
font-size: 30px;
font-family: "Myriad Web Pro", Palatino, "Palatino Linotype", "Times New Roman", "Times Italic";
}
h12 {
text-align: center;
color: #000000;
font-style: normal;
font-size: 20px;
font-family: "Myriad Web Pro", Palatino, "Palatino Linotype", "Times New Roman", "Times Italic";
font-weight: bold;
}
h13 {
text-align: center;
color: #000000;
font-style: normal;
font-size: 20px;
font-family: "Myriad Web Pro", Palatino, "Palatino Linotype", "Times New Roman", "Times Italic";
font-weight: normal;
}
h14 {
text-align: center;
color: #006CFF;
font-style: normal;
font-size: 20px;
font-family: "Myriad Web Pro", Palatino, "Palatino Linotype", "Times New Roman", "Times Italic";
font-weight: bold;
}
a.header:link {
color: #000000;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;
font-size: 22px;
text-decoration: none;
font-style: normal;
font-weight: bold;
font-variant: small-caps;
}
a.header:visited {
color: #000000;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;
font-size: 22px;
text-decoration: none;
font-style: normal;
font-weight: bold;
font-variant: small-caps;
}
a.header:hover {
color: #0069CC;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;
font-size: 22px;
text-decoration: none;
font-style: normal;
font-weight: bold;
font-variant: small-caps;
}
a.header:active {
color: #000000;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;
font-size: 22px;
text-decoration: none;
font-style: normal;
font-weight: bold;
font-variant: small-caps;
}
#menu {
margin-left: 33px;
position: relative;
top: 165px;
}
.row a {
margin: 0 20px 0 4px;
}
.row a:nth-child(3) {
margin-left: 310px;
}
.row a:nth-child(2) {
margin-left: 12px;
}
.row a:nth-child(1) {
margin-left: 20px;
}
<body>
<div id="headerwrap">
<header>
<div class="row" id="menu">
<a href="latestindexv1.html" class="header">Home</a>
<a href="coinmarket.html" class="header">Coin Market</a>
<a href="autobuyer.html" class="header">Autobuyer</a>
<a href="contact.html" class="header">Contact </a>
</div>
</header>
</headerwrap>
<div id="contentmain">
<br>
<br>
<br>
<br>
<h13>
<p>text</p>
<p>text</p>
<p>text</p>
</h13>
<div id="form">
<iframe src="https://docs.google.com/forms/d/1aEWswORyYcfzLGW6sCEYN3IKY75rXoxYG7750ikMbjI/viewform?embedded=true" width="560" height="950" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>
</div>
</div>
<div id="push"> </div>
<footer>
<a href="http://www.skype.com" class="nl" target="blank" title="skype">
<img src="images/footer_icons/skype_off.png" width="40" height="40" onmouseover="this.src='images/footer_icons/skype_on.png'" onmouseout="this.src='images/footer_icons/skype_off.png'" border="0" />
</a>
<a href="http://www.skype.com" class="nl" target="blank" title="youtube">
<img src="images/footer_icons/youtube_off.png" width="40" height="40" onmouseover="this.src='images/footer_icons/youtube_on.png'" onmouseout="this.src='images/footer_icons/youtube_off.png'" border="0" />
</a>
<a href="WEBSITE URL HERE" class="nl" target="blank" title="email">
<img src="images/footer_icons/mail_off.png" width="40" height="40" onmouseover="this.src='images/footer_icons/mail_on.png'" onmouseout="this.src='images/footer_icons/mail_off.png'" border="0" />
</a>
<a href="WEBSITE URL HERE" class="nl" target="blank" title="viber">
<img src="images/footer_icons/viber_off.png" width="40" height="40" onmouseover="this.src='images/footer_icons/viber_on.png'" onmouseout="this.src='images/footer_icons/viber_off.png'" border="0" />
</a>
<h4>All copyrights belong to their respective owners.
<br><br>
2015 ⚽ SamArt Studio</h4>
</footer>
</body>
Upvotes: 1
Reputation:
In your example, you must change </headerwrap>
to </div>
in the HTML and change footer
to position: fixed;
in the CSS.
Upvotes: 1