Sticky footer on fixed position sidebar, want css solution - html

I used the technique of sticky footer provided by Martin Bean and Ryan Fait for a while, works fine until I find myself needs to put a sticky footer on a fixed position sidebar.
Since fixed position sidebar is invisible to the document, the setting of margin and padding in the wrapper has no effect. I tried to add another inner-wrapper inside the sidebar but also not helping. I would like to know if there's any pure CSS solution for this request?
The reason I have to use fixed positioning sidebar is I use transitioning effect to collapse it when screen size is small. The method is learned from StartBootstrap, example simple-sidebar.
BTW: I'm using BS3
The basic set up of my site is:
HTML
<div id="wrap">
<div id="sidebar-wrapper">
<div id="inner-wrap">
<ul id="sidebar-nav">
<li>...</li>
<li>...</li>
</ul>
</div>
<div id="footer">
Copyright claim
</div>
</div>
<div id="main-wrapper">
Some Content
</div>
</div>
CSS
html, body {
height: 100%;
}
#wrap {
height: 100%;
}
#sidebar-wrapper {
width: 250px;
position: fixed;
min-height: 100%;
height: auto !important;
height: 100%;
padding: 0 auto 50px;
margin: 0 auto -50px;
}
#inner-wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -50px;
padding: 0 auto 50px;
width: 100%;
}
#sidebar-nav {
position: relative;
top: 0px;
width: 250px;
margin: 0px;
padding: 0px;
}
#footer {
height: 50px;
position: absolute;
width: 250px;
}
I made a temp bootply. Hope it helps.
UPDATE
The problem is solved by Bass. Thanks a lot! The cause of the above code not working is due to the extra 'height: auto !important;' set in the parent #sidebar-wrapper. Delete it then everything works fine. If you like, you can also delete the position:absolute in #footer as well.

I seems to me you can do the same with an extra wrapper on your sidebar:
html
<!-- Sidebar -->
<div id="sidebar-wrapper">
<div id="sidebar-wrapper-wrapper">
<ul class="sidebar-nav">
<li class="sidebar-brand">Start Bootstrap</li>
<li>Dashboard</li>
<li>Shortcuts</li>
<li>Overview</li>
<li>Events</li>
<li>About</li>
<li>Services</li>
<li>Contact</li>
</ul>
</div>
<div style="background-color:red;height:60px">footer</div>
</div>
css
#sidebar-wrapper-wrapper {
height: auto !important;
margin: 0 auto -60px;
min-height: 100%;
padding: 0 0 60px;
}

Related

Navigation position fixed - impossible to align to the right

I'm being unable to align the navigation to the right side while it's positioned fixed.
I read previous threads and I implemented what was suggested but despite of that I'm not able to make it stay within the main container and to be aligned to the right.
It either doesn't move at all (with float: right) or goes out of the container.
<div class="container">
<nav id="site-navigation" class="main-navigation" role="navigation">
<div class="nav-positioning">
<div class="menu-primary-navigation-container">
<ul id="primary-menu" class="menu nav-menu">
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
</nav><!-- #site-navigation -->
</div>
.container {
max-width: 1280px;
margin-left: auto;
margin-right: auto;
padding: 30px;
box-sizing: border-box;
}
header .main-navigation {
position: fixed;
padding: 20px 0;
z-index: 3;
width: auto;
}
.main-navigation {
clear: both;
display: block;
}
The problem occurs within this site: www.oktawiakata.com
login: login
password: superstrongpassword
Thanks a lot in advance for your hints!
I'm not able to make it stay within the main container and to be aligned to the right.
With position:fixed the position of your element will be relative to the browser window, so it's not exactly correct to say that it will stay within the main container in CSS terms.
If you want it to stay within the main container, you should use position: absolute
#main-container{
position: relative;
}
#navigation{
position: absolute;
right: 0;
}
UPDATE:
Use this code for a navigation bar like the example provided on your comment:
HTML
<div id="navigation-bar">
<div class="navigation-content">
<ul class="navigation-menu">
<!-- Your <li> elements here -->
</ul>
</div>
</div>
CSS
#navigation-bar{
position: fixed;
top: 0;
right: 0;
left: 0;
height: auto;
padding: 15px 0px;
}
#navigation-bar .navigation-content{
width: 1280px;
margin: auto;
text-align: right
}
#navigation-bar .navigation-content ul{
// Your list styles ...
}
When your element is positioned as a fixed element, then you need to change right value to 0px;
#someContainerCSS{
position: fixed;
right : 0px;
}
That should do the work.

HTML/Body does not encapsulate entire height

This is a quick mock-up to create a full-size webpage, however whenever I test this, a small margin of space is present at the top of the screen.
How can I get rid of this small space at the top?
HTML
<body>
<div id="container">
<header id="header">
<div class="header_container">
<h1 class="header_logo">Blog</h1>
<nav class="menu_nav">
</nav>
</div>
</header>
</div>
</body>
CSS
body,html {
margin: 0;
height: 100%;
}
#container{
height: 100%;
width: 100%;
background-color: orange;
}
#header {
width: 100%;
height: 80px;
background-color: green;
}
.header_container{
margin-left: 50px;
margin-right: 50px;
}
This is being caused by the margin on the top of the h1.
To fix this, either give the header a property of overflow:hidden to make the header taller, or remove the margin of the h1 using margin-top:0.
JSFiddle: http://jsfiddle.net/jdwire/8QV4f/

adding one DIV creates many white space

I have the following HTML / CSS code:
HTML
<div id = "content-wrapper">
<div class="stickyheader">
<div id="logo"></div>
<div class="nav">
<ul class="top_nav">
<li>Home</li>
...
</ul>
</div>
</div>
<div id="content-wrapper">
<div class="central_img_front">Some text</div>
<div class="welcome_container">Test</div>
</div>
...
</div>
CSS
.stickyheader {
background-color: white;
width: 100%;
height: 138px;
padding-top: 24px;
z-index: 1;
position: fixed;
top: 0;
}
#content-wrapper {
width:1000px;
margin:0px auto;
position: relative;
min-height: 100%;
height: auto !important;
height: 100%;
margin-top: 162px;
}
.welcome_container {
margin: 413px auto 55px auto;
text-align: center;
width: 760px;
}
.central_img_front {
background-image: url(http://modeles-de-lettres.org/test/images/slide12.jpg);
width: 1920px;
height: 413px;
position:absolute;
left:-460px;
}
Full JSFiddle code is here: http://jsfiddle.net/ugnmc/
My problem is with content-wrapper part. There are two divs inside this div:
div.central_img_front
div.welcome_container
I need those divs to be exactly under div.stickyheader. Now as you can see in fiddle, div.central_img_front is pushed too far to the bottom (there are a lot of white space under div.stickyheader).If I remove div.welcome_container from HTML then everything is OK. So,
I really cannot get it - why div.welcome_container affects div.central_img_front?
EDIT:
div.central_img_front
is positioned absolute, because it is in container (wrapper). If I remove position:absolute, then it is positioned incorrectly and .
The white space is caused by .welcome-container, which has a huge margin-top.
Demo
Change is:
.welcome_container {
margin: 0px auto 55px auto;
// was margin: 413px auto 55px auto;
text-align: center;
width: 760px;
}
The position:absolute takes the div.central_img_front out of line and the div.welcome_container slides in before it. Can you just remove it?
hei men, check these fiddle, http://jsfiddle.net/N269j/.
The problem are the margings and the heights.

Div Background Image Z-Index Issue

I am trying to get the background image of my content to appear behind the header and footer. Currently, the top of the content's background is sticking out onto the header, and you can see that the bottom has slightly covered the footer (notice the slight change of the footer's border colour). I have tried setting applying z-index:-100; to content which worked but also makes the text unselectable. I then tried applying z-index:1; to content, but that did not make the content appear under the header/footer.
link to website
//html
<div id="wrapper">
<header>
<div id="logo"></div>
<nav>
<ul>
<li id="aboutNav">home</li>
<li id="menuNav">menu</li>
<li id="specialsNav">specials</li>
</ul>
</nav>
</header>
<div id="content">
content <br> goes <br> here <br>
google
</div>
</div>
<footer>
<div id="thumbsDesc"></div>
<div id="thumbs"></div>
</footer>
//css
header {
width: 100%;
height: 100px;
background: url(../img/top.png) repeat-x;
z-index: 110;
}
#wrapper #content {
color: #FFFFFF;
background: url(../img/body.png) repeat-y;
width: 524px;
padding: 25px 30px 25px 30px;
position: absolute;
bottom: 100px;
top: 90px;
margin: 0 0 0 150px;
z-index: 1;
}
footer {
margin: -107px 0 0 0;
width: 100%;
height: 107px;
background: url(../img/bottom.png) repeat-x;
z-index: 100;
}
To solve the issue, you are using the z-index on the footer and header, but you forgot about the position, if a z-index is to be used, the element must have a position:
Add to your footer and header this CSS:
position: relative;
EDITED:
Also noticed that the background image on the #backstretch has a negative z-index, don't use that, some browsers get really weird...
Remove From the #backstretch:
z-index: -999999;
Read a little bit about Z-Index here!
For z-index to work, you also need to give it a position:
header {
width: 100%;
height: 100px;
background: url(../img/top.png) repeat-x;
z-index: 110;
position: relative;
}
Set your header and footer position to "absolute" and that should do the trick. Hope it helps and good luck with your project!

Making my DIV stretch to fill the available page space with valid CSS in IE

I'm trying to make a simple DIV layout compatible with IE, and it's giving me hell.
Here's the basic layout I'm working for:
<div id="body" style="background: blue;">
<div id="header">
HEADER
</div>
<div id="content" style="height: 88%;">
CONTENT HERE
</div>
<div id="footer">
FOOTER
</div>
</div>
I'm using CSS rounded corners on the Body div, and I have a navbar and footer info in #footer as well as a tabbed main navbar in #header.
My main problem has been making the #content div stretch vertically to fit the full page when I only have a small amount of content WITHOUT creating vertical scrollbars.
If I make #content height: 100%; the header and footer cause the page's height to go above 100% and triggers scrollbars.
Making #content's height 88% does the trick in FireFox, but there are two problems with this solution:
a) It's an ugly hack
b) It doesn't work in IE (of course).
Anyone have ideas on how to accomplish this? I assume is should be a fairly common situation for web designers out there.
There you go, try this template, it's really simple and i think it would solve your problem.
HTML:
<div id="wrapper">
<div id="header">
<div id="header_900">
<p>header</p>
</div><!--header_900-->
</div>
<div id="content">
<div id="content_900">
<p>content</p>
</div> </div>
</div><!--wrapper-->
<div id="footer">
<div id="footer_900">
<p>footer</p>
</div> </div>
CSS
body, html{
height: 100%;
}
body, p {
margin: 0; padding: 0;
}
#wrapper {
min-height: 100%;
}
* html #wrapper {
height: 100%;
}
/*HEADER------------------------------------*/
#header {
width: 100%;
background: #666;
}
#header_900 {
width: 960px;
height: 100px;
margin: 0 auto;
position: relative;
overflow: hidden;
}
/*FOOTER------------------------------------*/
#footer {
width: 100%;
height: 100px;
margin: -100px auto 0 auto; /*THIS SHOULD BE EQUAL TO THE FOOTERS HEIGHT*/
position: relative;
background: #666;
}
#footer_900 {
width: 960px;
height: 100px;/*THIS IS THE FOOTERS HEIGHT*/
position: relative;
margin: 0 auto;
}
/*CONTENT------------------------------------*/
#content {
width: 100%;
padding-bottom: 100px; /*THIS SHOULD BE EQUAL TO THE FOOTERS HEIGHT*/
}
#content_900 {
width: 960px;
margin: 0 auto;
overflow: hidden;
}
I don't think there is an official way to accomplish this unless you use quirks mode. If you use quirks mode (no doctype), it would look something like this:
html, body {
margin: 0;
padding: 0;
height: 100%:
}
#content {
height: 100%:
}
Maybe what you're looking for is an adapted version of something like this: http://www.alistapart.com/comments/fauxcolumns