Sticky footer with Sidebar - html

I would like to add the Bootstrap Sticky Footer example to the white area of this Simple Sidebar example.
I am struggling as I cannot get it working. Either I fail when the content does not fit the screen or I fail when the content exceeds it.
Any hint?
Thank you all.

Just make sure the div is centered within the white area.
Then use position absolute or relative in the styling.
Take a look at my code and pay attention to where the footer div is placed in the html and how the styling is written. Hopefully this helps.
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Simple Sidebar - Start Bootstrap Template</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/simple-sidebar.css" rel="stylesheet">
<style>
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background-color: #f5f5f5;
}
</style>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<div id="wrapper">
<!-- Sidebar -->
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li class="sidebar-brand">
<a href="#">
Start Bootstrap
</a>
</li>
<li>
Dashboard
</li>
<li>
Shortcuts
</li>
<li>
Overview
</li>
<li>
Events
</li>
<li>
About
</li>
<li>
Services
</li>
<li>
Contact
</li>
</ul>
</div>
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<h1>Simple Sidebar</h1>
<p>This template has a responsive menu toggling system. The menu will appear collapsed on smaller screens, and will appear non-collapsed on larger screens. When toggled using the button below, the menu will appear/disappear. On small screens, the page content will be pushed off canvas.</p>
<p>Make sure to keep all page content within the <code>#page-content-wrapper</code>.</p>
Toggle Menu
<footer class="footer">
<div class="container">
<p class="text-muted">Place sticky footer content here.</p>
</div>
</footer>
</div>
</div>
</div>
</div>
<!-- /#page-content-wrapper -->
</div>
<!-- /#wrapper -->
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Menu Toggle Script -->
<script>
$("#menu-toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});
</script>

There's a sticky-footer-navbar.css that seems to be missing in Sidebar Example. Here's the contents of that css file
/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by footer height */
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 60px;
background-color: #f5f5f5;
}
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
body > .container {
padding: 60px 15px 0;
}
.container .text-muted {
margin: 20px 0;
}
.footer > .container {
padding-right: 15px;
padding-left: 15px;
}
code {
font-size: 80%;
}

From Bootstrap 4 you need to change the style so rather than the body you put the margin on page-content-wrapper.
/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}
#page-content-wrapper {
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 60px;
background-color: #f5f5f5;
}

Related

Bootstrap 4 Sticky Footer Not Sticking

Not really sure why the sticky footer isn't working in Bootstrap 4. I have a TYPO3 website which I am a beginner at.
The sticky footer is not sticking at the bottom of the page.
Here is a copy of the page source as it has been rendered.
I basically copied the html file from bootstraps docs folder and then modified it and copied it into my TYPO3 template.
If I fill the page with content, the footer does not stick - I have to scroll the page down to see it.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Landing Page</title>
<meta name="generator" content="TYPO3 CMS">
<link rel="stylesheet" type="text/css"
href="/typo3temp/assets/css/d42b6e1bdf.css?1507853162" media="all">
<link rel="stylesheet" type="text/css"
href="/fileadmin/templates/landing_page/css/bootstrap.min.css?1507860230"
media="all">
<link rel="stylesheet" type="text/css"
href="/fileadmin/templates/landing_page/css/sticky-footer.css?1507861966"
media="all">
<script
src="/fileadmin/templates/landing_page/js/jquery-3.2.1.min.js?1507862465"
type="text/javascript"></script>
<script
src="/fileadmin/templates/landing_page/js/tether.min.js?1507862602"
type="text/javascript"></script>
<script
src="/fileadmin/templates/landing_page/js/bootstrap.min.js?1507854311"
type="text/javascript"></script>
</head>
<body>
<div class="container">
<div class="mt-1">
<h1>Sticky footer</h1>
</div>
<p class="lead">Pin a fixed-height footer to the bottom of the
viewport in desktop browsers with this custom HTML and CSS.</p>
<p>
Use <a href="../sticky-footer-navbar">the sticky footer with a
fixed navbar</a> if need be, too.
</p>
<div class="row">
<div class="col">1 of 3</div>
<div class="col">1 of 3</div>
<div class="col">1 of 3</div>
</div>
</div>
<footer class="footer">
<div class="container">
<span class="text-muted">Place sticky footer content here.</span>
</div>
</footer>
</body>
</html>
Update 2020 - Bootstrap 4.5+
Now that Bootstrap 4 is flexbox, it's easier to use flexbox for the sticky footer.
<div class="d-flex flex-column min-vh-100">
<nav>
</nav>
<main class="flex-fill">
</main>
<footer>
</footer>
</div>
Bootstrap 4.0 Sticky Footer (4.0.0)
Simple Footer at Bottom Example (4.5.0)
Note: The flex-fill utility was included in Bootstrap 4.1 at later release. So after that release the extra CSS for flex-fill won't be needed. Additionally min-vh-100 is included in newer Bootstrap 4 releases.
Also see: Bootstrap 4 - Sticky footer - Dynamic footer height
Managed to figure it out. Maybe I have a misunderstanding on what "Sticky" is or something, but the solution was to change absolute -> fixed in the css file.
e.g. from:
.footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 60px;
line-height: 60px; /* Vertically center the text there */
background-color: #f5f5f5;
}
to:
.footer {
position: fixed;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 60px;
line-height: 60px; /* Vertically center the text there */
background-color: #f5f5f5;
}
The example in the Bootstrap 4 docs has the following CSS:
/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 60px; /* Margin bottom by footer height */
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px; /* Set the fixed height of the footer here */
line-height: 60px; /* Vertically center the text there */
background-color: #f5f5f5;
}
You've probably forgotten to set html { position: relative; min-height: 100%; } - I know I usually forget that part.
In Bootstrap 4, use the fixed-bottom class to stick your footer. No custom CSS needed:
<footer class="footer fixed-bottom">
...
</footer>
<html class="h-100">
.
.
</html>
This should solve the problem. It is similar to Benjineer's answer but ready bootstrap class.
Tested with Bootstrap 4.3.1
if you use
<footer class="footer fixed-bottom">
...
</footer>
remember to add
html {
padding-bottom: >= footer height;
}
to the CSS
to avoid blocking some content at the bottom of your page

How to center an image vertically on the balance of the space left on a page (less navbar/header & footer) and have a background image?

I see that this question has been asked before but with different elements used. I want the balance of space that is left (less header and footer space) to have the image smack in the middle no matter the size of the viewer's screen / browser.
I've tried sooooo many codes that I've read here but always either
a. something becomes messed up on the page and/or
b. the image still isn't vertically centered on the page itself (unless the page itself doesn't contain all my bits) though fixes center it in the middle of a space allocated but that space isn't centered vertically on the page.
EDIT NOTE: The answers below by roopa only resolved the Footer issue that I had included in this post as vertically centered image fixes I tried messed it up too.
EDIT 2: I have found the solution and have posted it as an Answer.
Thank you.
Here are the current codes: http://jsbin.com/vazevamile/edit?html,output
And a Stack Snippet:
/* chrome android to show background-image */
html{
height:100%;
min-height:100%;
}
body {
overflow-x: hidden;
padding-top: 50px; /* Padding for .navbar-fixed-top. Change value if navbar height changes. Remove if using .navbar-static-top. */
font-family: 'Didact Gothic', sans-serif, calibri, "lucida sans", verdana, arial, monospace;
font-size: 12px;
/* chrome android to show background-image */
min-height:100%;
/* .end */
/*keep footer at bottom*/
height:100%;
margin:0; /* for footer*/
/* .end*/
padding: 0 2em; /* top, right, bottom, and left*/
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
color: #ffff;
background-color: #B4A890;
background-image: url("http://www.planwallpaper.com/static/images/Fall-Nature-Background-Pictures.jpg");
background-position:absolute;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
background-size: cover;
}
/* resize images as windows shrinks */
img {
max-width: 100%;
height: auto;
width: auto\9; /* ie8 */
}
/* CSSReset.com - How To Keep Footer At Bottom of Page with CSS
* http://www.cssreset.com/2010/css-tutorials/how-to-keep-footer-at-bottom-of-page-with-css/*/
#wrapper {
min-height:100%;
position:relative;
}
#header {
background:#ededed;
padding:0px;
}
}
#content {
position:relative;
padding:50px 0;
/*background-color:black; - for testing*/
}
/* orginal, before footer background fix:
#content {
padding:50px; /*padding for navbar at the top*/
/* padding-bottom:100px; /*value must be equal to or greater than the height of #footer*/
/*background-color:black; - for testing*/
/*}*/
#footer {
background:#000000;
width:100%;
min-height:100px; /*for footer background fix*/
/*height:100px; - orginal before footer background fix*/
position:absolute;
bottom:0;
left:0;
font-size: 15px;
}
<!DOCTYPE html>
<html lang="en">
<meta name="robots" content="index, follow">
<meta http-equiv="imagetoolbar" content="no">
<meta http-equiv="language" content="en">
<head>
<!-- MenuBar - below 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- ./3 meta tags -->
<!-- MenuBar - Bootstrap Core CSS (ddmenu.js, jquery.js & bootstrap.js are the bottom for faster loading)-->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<!-- MenuBar & Mine Custom CSS -->
<link href="css-mb/main.css" rel="stylesheet">
<!-- /.custom css -->
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!--for footer bottom:-->
<!--[if lt IE 7]>
<style type="text/css">
#wrapper { height:100%; }
</style>
<![endif]-->
</head>
<body>
<div id="wrapper">
<div id="header">
<!-- MenuBar Navigation -->
<a id="ddmenuLink" href="menu_bar.htm">Menu</a>
<script src="js-mb/jsfiddle.js"></script>
<!-- /.navigation -->
</div><!--.header-->
<div id="content">
<center><img src="http://oi64.tinypic.com/k3sz9x.jpg" width="840" height="166"></center>
</div><!--.content-->
<div id="footer">
<center><TABLE BORDER=0><TR>
<TD><b><center>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque venenatis ante vitae interdum feugiat. Duis pretium diam quis justo fermentum efficitur. Pellentesque justo tortor, vulputate quis suscipit ut, lobortis eu massa. Donec vitae nisi sagittis, dictum eros pulvinar, finibus turpis. Nullam</center></b></TD>
</TR></TABLE></center>
<p><center><b>FOOTER</b></center></p>
</div><!--.footer-->
</div><!--.wrapper-->
<!-- MenuBar - jQuery & JavaScript are required for the dropdown menu. Placed at the end of the document so the pages load faster -->
<script src="http://m.uploadedit.com/ba3s/1492400858966.txt" type="text/javascript"></script>
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.js"></script>
<!-- Bootstrap core JavaScript-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script>
</body>
</html>
I have checked this code in my local server and footer is working fine as per your requirement.
So please implement it and let me know how is this working.
<!DOCTYPE html>
<html lang="en">
<meta name="robots" content="index, follow">
<meta http-equiv="imagetoolbar" content="no">
<meta http-equiv="language" content="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="css-mb/main.css" rel="stylesheet">
<style>
body {
padding-top: 50px; /* Padding for .navbar-fixed-top. Change value if navbar height changes. Remove if using .navbar-static-top. */
font-family: 'Didact Gothic', sans-serif, calibri, "lucida sans", verdana, arial, monospace;
font-size: 12px;
min-height:100%;
height:100%;
margin:0; /* for footer*/
/* .end*/
padding: 0 2em; /* top, right, bottom, and left*/
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
color: #ffff;
background-color: #B4A890;
background-image: url("http://www.planwallpaper.com/static/images/Fall-Nature-Background-Pictures.jpg");
background-position:absolute;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
background-size: cover;
}
/* resize images as windows shrinks */
img {
max-width: 100%;
height: auto;
width: auto\9; /* ie8 */
}
#wrapper {
min-height:100%;
position:relative;
}
#header {
background:#ededed;
padding:0px;
}
#content {
padding: 0;
display: table;
width: 100%;
height: 520px;
}
#content center{
display: table-cell;
vertical-align: middle;
}
#footer {
background:#000000;
width:100%;
min-height:50px;
bottom:0;
left:0;
font-size: 15px;
position: fixed;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="header">
<!-- MenuBar Navigation -->
<a id="ddmenuLink" href="menu_bar.htm">Menu</a>
<script src="js-mb/jsfiddle.js"></script>
<!-- /.navigation -->
</div><!--.header-->
<div id="content">
<center><img src="http://r69.cooltext.com/rendered/cooltext240617569866922.png" class="img-resposive" ></center>
</div><!--.content-->
<div id="footer">
<center>
<TABLE BORDER=0>
<TR>
<TD><b><center>blah blah <br>blah blah <br>blah blah <br></TD>
</TR>
</TABLE>
</center>
<p><center><b>FOOTER</b></center></p>
</div><!--.footer-->
</div><!--.wrapper-->
<!-- MenuBar - jQuery & JavaScript are required for the dropdown menu. Placed at the end of the document so the pages load faster -->
<script src="http://m.uploadedit.com/ba3s/1492400858966.txt" type="text/javascript"></script>
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.js"></script>
<!-- Bootstrap core JavaScript-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script>
</body>
</html>
For the image verticle alignment issue. I am trying to implement a perfect solution.
Thanks,
Please check the below mentioned code:
<!DOCTYPE html>
<html lang="en">
<meta name="robots" content="index, follow">
<meta http-equiv="imagetoolbar" content="no">
<meta http-equiv="language" content="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="css-mb/main.css" rel="stylesheet">
<style>
body {
padding-top: 50px; /* Padding for .navbar-fixed-top. Change value if navbar height changes. Remove if using .navbar-static-top. */
font-family: 'Didact Gothic', sans-serif, calibri, "lucida sans", verdana, arial, monospace;
font-size: 12px;
/* chrome android to show background-image */
min-height:100%;
/* .end */
/*keep footer at bottom*/
height:100%;
margin:0; /* for footer*/
/* .end*/
padding: 0 2em; /* top, right, bottom, and left*/
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
color: #ffff;
}
/* resize images as windows shrinks */
img {
max-width: 100%;
height: auto;
width: auto\9; /* ie8 */
}
#wrapper {
min-height:100%;
position:relative;
}
#header {
background:#ededed;
padding:0px;
}
#content {
position:relative;
padding:50px 0;
/*background-color:black; - for testing*/
}
#footer {
background:#000000;
width:100%;
min-height:100px;
bottom:0;
left:0;
font-size: 15px;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="header">
<!-- MenuBar Navigation -->
<a id="ddmenuLink" href="menu_bar.htm">Menu</a>
<script src="js-mb/jsfiddle.js"></script>
<!-- /.navigation -->
</div><!--.header-->
<div id="content">
<center><img src="http://r69.cooltext.com/rendered/cooltext240617569866922.png" class="img-resposive" ></center>
</div><!--.content-->
<div id="footer">
<center><TABLE BORDER=0><TR>
<TD><b><center>1. Problem: Image Above - Can't center vertically.<br>
2. Problem: This Footer - Background is fixed (100px), when screen is smaller (collapsed) the footer background isn't tall enough to cover the collapsed footer text. (If I use width 100% & 'margin:auto;' the text is fixed and won't collapse on smaller screens.)</center></b></TD>
</TR></TABLE></center>
<p><center><b>FOOTER</b></center></p>
</div><!--.footer-->
</div><!--.wrapper-->
<!-- MenuBar - jQuery & JavaScript are required for the dropdown menu. Placed at the end of the document so the pages load faster -->
<script src="http://m.uploadedit.com/ba3s/1492400858966.txt" type="text/javascript"></script>
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.js"></script>
<!-- Bootstrap core JavaScript-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script>
</body>
</html>
<!-- end snippet -->
<!DOCTYPE html>
<html lang="en">
<meta name="robots" content="index, follow">
<meta http-equiv="imagetoolbar" content="no">
<meta http-equiv="language" content="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="css-mb/main.css" rel="stylesheet">
<style>
body {
padding-top: 50px; /* Padding for .navbar-fixed-top. Change value if navbar height changes. Remove if using .navbar-static-top. */
font-family: 'Didact Gothic', sans-serif, calibri, "lucida sans", verdana, arial, monospace;
font-size: 12px;
min-height:100%;
height:100%;
margin:0; /* for footer*/
/* .end*/
padding: 0 2em; /* top, right, bottom, and left*/
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
color: #ffff;
}
/* resize images as windows shrinks */
img {
max-width: 100%;
height: auto;
width: auto\9; /* ie8 */
}
#wrapper {
min-height:100%;
position:relative;
}
#header {
background:#ededed;
padding:0px;
}
#content {
padding: 0;
height: 300px;
display: table;
width: 100%;
}
#content center{
display: table-cell;
vertical-align: middle;
}
#footer {
background:#000000;
width:100%;
min-height:100px;
bottom:0;
left:0;
font-size: 15px;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="header">
<!-- MenuBar Navigation -->
<a id="ddmenuLink" href="menu_bar.htm">Menu</a>
<script src="js-mb/jsfiddle.js"></script>
<!-- /.navigation -->
</div><!--.header-->
<div id="content">
<center><img src="http://r69.cooltext.com/rendered/cooltext240617569866922.png" class="img-resposive" ></center>
</div><!--.content-->
<div id="footer">
<center>
<TABLE BORDER=0>
<TR>
<TD><b><center>1. Problem: Image Above - Can't center vertically.<br>
2. Problem: This Footer - Background is fixed (100px), when screen is smaller (collapsed) the footer background isn't tall enough to cover the collapsed footer text. (If I use width 100% & 'margin:auto;' the text is fixed and won't collapse on smaller screens.)</center></b>
</TD>
</TR>
</TABLE>
</center>
<p><center><b>FOOTER</b></center></p>
</div><!--.footer-->
</div><!--.wrapper-->
<!-- MenuBar - jQuery & JavaScript are required for the dropdown menu. Placed at the end of the document so the pages load faster -->
<script src="http://m.uploadedit.com/ba3s/1492400858966.txt" type="text/javascript"></script>
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.js"></script>
<!-- Bootstrap core JavaScript-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script>
</body>
</html>
I’m having a mini CSS celebration here ;) . I woke up in the middle of the night and realized I was going about it the wrong way. The image couldn’t center as it didn’t know the size of the container to be center in.
1. So first I needed to have a container that would take up the balance of the empty space no matter the size of the window (found here: http://jsfiddle.net/WdrDH/ ):
/* Height less (header + footer) */
section {
height: calc(100% - (50px + 25px));
}
Then to center the image, any size image (found here http://codepen.io/sebastianekstrom/pen/kzEhe and here: css3: translateX to center element horizontally ):
.image img {
position: relative;
left: 50%;
top: 50%;
-webkit-transform: translateX(-50%) translatey(-50%);
-moz-transform: translateX(-50%) translatey(-50%);
transform: translateX(-50%) translatey(-50%);
}
You'll need this too:
img {
max-width: 100%;
height: auto;
width: auto\9; /* ie8 */
}
html part for section and image:
<section class="image">
<img src="https://yourimage.com/image.jpg" width="840" height="166">
</section>
I've included all my other bits (menu, background image, etc.) to demonstrate they aren't messed up. Find here https://jsfiddle.net/4dcuaen2/ and below:
/* chrome android to display background-image */
html{
height:100%;
min-height:100%;
}
body {
overflow-x: hidden;
padding: 50px 20px 0px 20px;/* 50px: for .navbar-fixed-top.*/
font-family: 'Didact Gothic', sans-serif, calibri, "lucida sans", verdana, arial, monospace;
font-size: 12px;
/* chrome android to dispaly background-image */
min-height:100%;
/* .end */
/*keep footer at bottom*/
height:100%;
margin:0; /* for footer*/
/* .end*/
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
color: #ffff;
background-color: #B4A890;
background-image: url("http://www.planwallpaper.com/static/images/Fall-Nature-Background-Pictures.jpg");
background-position:absolute;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
background-size: cover;
}
/* RELEVANT CODE TO CENTERING AN IMAGE HORIZONTALLY & VERTICALLY NO MATTER THE SIZE OF THE WINDOW: */
/* 1. Container to use balance of the space: */
/* Height less (header + footer).
(Note: My footer is 70, but if use 70 it places extra space below footer and the need to scroll even if window is larger.) */
section {
height: calc(100% - (50px + 25px));
/* Container border for visual testing*/
border: 2px solid red;
}
/* 2. Center image vertically & horizontally */
.image img {
position: relative;
left: 50%;
top: 50%;
-webkit-transform: translateX(-50%) translatey(-50%);
-moz-transform: translateX(-50%) translatey(-50%);
transform: translateX(-50%) translatey(-50%);
}
/* .END OF RELEVANT CODE */
/* resize images as windows shrinks */
img {
max-width: 100%;
height: auto;
width: auto\9; /* ie8 */
}
#footer {
width:100%;
min-height:70px; /*for footer background fix*/
bottom:0;
left:0;
font-size: 13px;
/* Container border for visual testing*/
border: 1px solid blue;
}
.foot {
padding: 10px 0;
text-align: center;
color: #ffffff;
font-size:13px;
letter-spacing: 2px;
}
<!DOCTYPE html>
<html lang="en">
<meta name="robots" content="index, follow">
<meta http-equiv="imagetoolbar" content="no">
<meta http-equiv="language" content="en">
<head>
<!-- MenuBar - below 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- ./3 meta tags -->
<title>CENTERED</title>
<!-- MenuBar - Bootstrap Core CSS (ddmenu.js, jquery.js & bootstrap.js are the bottom for faster loading)-->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<!-- MenuBar & Mine Custom CSS -->
<link href="css-mb/main-SOLVED.css" rel="stylesheet">
<!-- /.custom css -->
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Logo and responsive toggle -->
<div class="navbar-header"> <!--This div creates a navigation button visible on smaller screens -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span><!--These tags create the standard 3-lin button logo on top right corner -->
<span class="icon-bar"></span><!--Put the page less than full-screen to see this behavior -->
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="navbar">
<ul class="nav navbar-nav">
<li>Home</li>
<li class="dropdown">Dropdown1<span class="caret"></span><!--Requires the JavaScript files linked at the end-->
<ul class="dropdown-menu">
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
</ul>
</li>
<li class="dropdown">Dropdown2<span class="caret"></span>
<ul class="dropdown-menu">
<li>AnotherItem</li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">Header:</li>
<li>MoreItems</li>
<li>MoreItems</li>
<li>MoreItems</li>
</ul>
</li>
<li>Tutorials</li>
<li>About</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<section class="image">
<img src="http://oi64.tinypic.com/k3sz9x.jpg" width="840" height="166">
</section>
<div id="footer">
<center>
<TABLE BORDER=0><TR id="sl">
<TD><i class="fa fa-1x fa-facebook"></i>FB </TD>
<TD><i class="fa fa-1x fa-youtube"></i>YT </TD>
<TD><i class="fa fa-1x fa-share-alt"></i>SH</span></TD>
</TR></TABLE>
</center>
<div class="foot">FOOTER TEXT</div><!--class foot-->
</div><!--.footer-->
<!-- MenuBar - jQuery & JavaScript are required for the dropdown menu. Placed at the end of the document so the pages load faster -->
<script src="http://m.uploadedit.com/ba3s/1492400858966.txt" type="text/javascript"></script>
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.js"></script>
<!-- Bootstrap core JavaScript-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script>
</body>
</html>

Setting footer bottom of page using bootstrap

Hi I am trying to stick the footer the bottom of the page even when my page is thin on content.
I have tried to use below CSS code but it does not work.
Any suggestions?
CSS
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by footer height */
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 60px;
background-color: #f5f5f5;
}
HTML
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<aside class="left-panel">
</aside>
<section class="content">
<header class="top-head container-fluid">
</header>
<!-- Header Ends -->
<div class="warper container-fluid">
<div class="page-header"><h1>Blank Template <small>Start new page with this</small></h1></div>
<!-- Work Here -->
</div>
<!-- Warper Ends Here (working area) -->
<footer class="container-fluid footer">
Copyright © 2014 test
<i class="fa fa-chevron-up"></i>
</footer>
</section>
<!-- Content Block Ends Here (right box)-->
</body>
</html>

Bootstrap, centering image vertically and horizontally with sticky footer

I am having trouble trying to center an image both horizontally and vertically, using Bootstrap and a sticky footer. It needs to be fluid, responsive and work on both desktops and mobiles.. I don't want the footer to go over the image if the window/screen size is too small (obviously).
Any help or insight would be great appreciated!
Here's what I've got..
404.php
<html lang="en">
<head>
<title>Error 404</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<title>Error 404</title>
<!-- Bootstrap -->
<link href="/assets/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles -->
<link href="/assets/css/sticky-footer.css" rel="stylesheet">
<link href="/assets/css/custom.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container-fluid">
<div class="panel-default">
<div class="panel-body">
<div class="text-center top"><h2>Error 404</h2>
</div>
<div class="form-group text-center">
<h4>Nothing to see here, nothing to see</h4>
<img src="/assets/images/404.jpg" class="img-responsive center-block">
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="text-muted text-center">
<small>© 2015</small>
</p>
</div>
</footer>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</body>
</html>
sticky-footer.css
/* Sticky footer styles */
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by footer height */
margin-bottom: 40px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 40px;
}
Sticky bottom footer
Bootstrap has a navbar that I find is useful for footers. Try using navbar navbar-default navbar-fixed-bottom instead of your custom footer class.
Center vertically
This question has a lot of great information regarding centering vertically. This is what I use:
.vertical-center {
min-height: 100%; /* Fallback for browsers do NOT support vh unit */
min-height: 100vh; /* These two lines are counted as one :-) */
display: flex;
align-items: center;
}
Center horizontally
I've found the easiest solution to centering horizontally is just using center-block. Hasn't failed me yet.
I would suggest you have a loook at this stackoverflow question first.
This might also get you started (change it in your sticky-footer.css):
.footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 40px;
display: table; /*<<<< this line was added*/
}
.container {
height: 100%;
display: table-cell;
vertical-align: middle;
}
.cent {
margin: 0 25% auto 25%;
}
Add the class cent to you paragraph in your webpage, i.e.:
<p class="cent text-muted text-center">
<small>© 2015</small>
</p>

Bootstrap sticky footer with image

What I am trying to achieve is a page with a sticky footer, which is a vector island.
The island is always at the bottom of the page, but when the browser height is too small it invokes vertical scrolling.
Behind the island is a sunburst that then falls behind all the page content. This is quite big, about 1417px high. This doesn't affect vertical scrolling though.
Here is what I have so far and I've been stuck for hours! Any help would be appreciated.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta content="" name="description">
<meta content="" name="author">
<link href="../../docs-assets/ico/favicon.png" rel="shortcut icon">
<title>Sticky Footer Template for Bootstrap</title><!-- Latest compiled and minified CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
html,
body {
height: 100%;
background-color: #6ec8e4;
}
#wrap {
min-height: 100%;
height: auto;
}
.testBox{
height: 300px;
width: 100%;
background: red;
margin: 20px 0;
}
.footer-image-container {
margin: 0 auto;
position: absolute;
width: 100%;
height: 1417px;
}
.footer-image {
position: absolute;
bottom: 0;
z-index: -1;
}
</style>
</head>
<body>
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Begin page content -->
<div class="container">
<div class="page-header">
<h1>Sticky footer</h1>
</div>
<div class="row">
<div class="testBox"></div>
</div>
<div class="row">
<div class="testBox"></div>
</div>
<div id="footer">
<div class="footer-image-container"><img class="img-responsive footer-image" src="http://i.imgur.com/wSNrfJD.png">
<img class="img-responsive footer-image" src="http://i.imgur.com/alDv0tE.png"></div>
</div>
</div>
</div><!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</body>
</html>
It would be better to use the images as background images in css:
see https://jsfiddle.net/6t9vxq1o/1/
.body{
height:100%;
background: url(http://i.imgur.com/wSNrfJD.png) no-repeat center bottom;
}
#wrap{
background:url(http://i.imgur.com/alDv0tE.png) no-repeat center bottom;
}
This way the images will be always on bottom, the sunburst behind the content, and the grass behind the footer