Reputation: 10972
I have a website in development here: http://184.173.208.195/~secoast/about/mission
and it is supposed to have a "sticky footer" however, in order to get the drop shadow to show correctly on the bottom of the content I have had to modify the code slightly. In doing so the footer now comes up over the bottom of the content on long pages.
Here is the code for the sticky footer:
/* Begin Sticky Footer code */
html, body, #wrap { height: 100%;}
body > #wrap { height: auto; min-height: 100%; }
#main { padding-bottom: 50px; } /* must be same height as footer
*/
body.inside #main {
height: 100%;
margin-top: 5px;
background: #fff url(../photos/bg_main.png) repeat-y;
position: relative;
-webkit-box-shadow: 3px 3px 5px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 3px 3px 5px rgba(50, 50, 50, 0.75);
box-shadow: 3px 3px 5px rgba(50, 50, 50, 0.75);
}
.white-bar-top {
width: 959px;
height: 20px;
margin-left: 1px;
background: #fff;
margin-top: -10px;
}
.white-bar-bottom {
width: 959px;
height: 20px;
clear: both;
background: #fff;
position: absolute;
bottom: 0;
left: 1px;
}
#footer {
position: relative;
width: 100%;
background-color: #dadfdb;
margin-top: -50px; /* negative value of footer height */
height: 50px;
clear: both;
}
Here is the html
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta Data -->
<meta charset="UTF-8">
<meta name="author" content="SE Coastal Wind Coalition">
<!-- Title -->
<title>Mission | About Us |SE Coastal Window Coalition</title>
<meta name='keywords' content='your, default, keywords, here' />
<meta name='description' content='Your default description here' />
<link rel='canonical' href='http://184.173.208.195/~secoast/about/mission' />
<!-- generated by seo_lite -->
<!-- Styles -->
<link rel="stylesheet" href="http://184.173.208.195/~secoast/css/styles.css?v=1.0">
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="http://184.173.208.195/~secoast/fancybox/jquery.fancybox.css?v=2.0.6" media="screen" />
<!-- Scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- <script src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js"></script> -->
<script src="http://184.173.208.195/~secoast/js/jquery.dropmenu.js"></script>
<script>
$(document).ready(function(){
$("#nav-one").dropmenu({
openAnimation: "size",
closeAnimation: "slide",
openSpeed: 300,
closeSpeed: 200,
closeDelay: 500,
zindex: 1000
});
});
</script>
<!-- Fancybox -->
<script type="text/javascript" src="fancybox/jquery.fancybox.js?v=2.0.6"></script>
<!-- page-specific scripts -->
</head>
<body class="inside base-3-col">
<div id="wrap">
<div id="header">
<!-- navigation code goes here -->
</div><!-- end #header -->
<div id="main" class="clearfix">
<img class="banner" src="http://184.173.208.195/~secoast//photos/banner-inside.jpg" alt="banner-inside" width="962" height="125" />
<div id="page-title-banner">
<h2>About the Southeast Coastal Wind Coalition</h2>
</div>
<div class="white-bar-top"></div>
<div id="section-sub-nav"><!-- this only shows on base-3-col pages -->
<ul>
<li><a href="#">Nav One</a></li>
<li><a href="#">Nav Two</a></li>
<li><a href="#">Nav Three</a></li>
<li><a href="#">Nav Four</a></li>
</ul>
</div>
<div id="sidebar-nav" class="clearfix">
<ul>
<li><a class="selected" href="http://184.173.208.195/~secoast/about/mission">Mission</a></li>
<li><a href="http://184.173.208.195/~secoast/about/members">Members</a></li>
<li><a href="http://184.173.208.195/~secoast/about/management">Management</a></li>
<li><a href="http://184.173.208.195/~secoast/about/board-of-directors">Board of Directors</a></li>
<li><a href="http://184.173.208.195/~secoast/about/state-policy-liaison">State Policy Liaison</a></li>
</ul>
</div>
<div id="main-content">
<h3>Our Mission</h3>
<p>
<img alt="" src="http://184.173.208.195/~secoast/images/uploads/offshoregrande.jpg" style="width: 610px; height: 440px; " /><br />
<span style="font-size:9px;"><span style="font-family:trebuchet ms,helvetica,sans-serif;">PHOTO: COURTESY OF SIEMENS AG @2013. ALL RIGHTS RESERVED.</span></span></p>
<p>
Page text goes here.</p>
</div><!-- end #content-two-thirds-->
<div class="white-bar-bottom" class="white-bar"></div>
</div><!-- end #main -->
</div><!-- end #wrap -->
<div id="footer">
<div id="footer-content">
<ul id="footer-nav">
<li class="no-icon"><a href="#">Donate</a></li>
<li class="no-icon"><a href="#">Contact</a></li>
<li><a class="social facebook" href="#">Facebook</a></li>
<li><a class="social twitter" href="#">Twitter</a></li>
<li><a class="social linkedin" href="#">LinkedIn</a></li>
<li><a class="social youtube" href="#">Youtube</a></li>
<li class="no-icon">©2012 Southeast Coastal Wind Coalition</li>
<li class="no-icon"><a href="http://www.rouviere.com">Website by Rouviere Media</a></li>
</ul>
</div><!-- end #footer-content -->
</div><!-- end #footer -->
</body>
</html>
I would appreciate any help in getting the footer to stay below the main content.
Thanks.
Upvotes: 0
Views: 4261
Reputation: 26066
It’s quite hard to recreate your page locally. You should consider creating a stand-alone sample of the issue that would allow others to debug.
But looking at your coding & your stated issue it seems that positioning your #footer
with a margin-top: -50px;
is what is causing the issue.
#footer {
position: relative;
width: 100%;
background-color: #dadfdb;
margin-top: -50px; /* negative value of footer height */
height: 50px;
clear: both;
}
You are positioning margin-top: -50px;
to get the footer to stay, but it is now overlapping -50px over your main content, right?
So maybe the solution is to give the immediate <div>
that comes before the footer a 50px margin—or even more—to compensate?
body.inside #wrap {
height: 100%;
margin-bottom: 50px;
}
Upvotes: 3
Reputation: 1570
I would suggest that you should do the HARD STOP thing by using Javascript by detecting the window height like below
var ht= window.innerHeight
if(ht< 760){
document.getElementById("footer").style = "width: 100%;background-color: #dadfdb;margin-top: -50px;height: 50px;clear: both;"
}else{
document.getElementById("footer").style = "width: 100%;background-color: #dadfdb;margin-top: -50px;height: 50px;clear: both;position:relative"
}
And you may also want to look into Jquery's resize event for the same Here
And offCourse Media-Queries is another way of doing the same. Please have a look here
Upvotes: 0