I'm using Less Framework 4 for two websites I'm designing. In both designs I want to apply a 5 pixel border both on top and bottom of the document.
The problem: because of the styles applied to body, I'm applying the border-bottom and border-top to the html object, so the bottom border never sticks to the bottom of the page like it would happen in a usual sticky footer situation.
Here are the screenshots for the two cases:
Here's the (LESS) CSS I'm using for html and body: pastie.org/private/us5x1vhjnwzq6zsiycnu2g
html {
border-top: solid #black 10px;
border-bottom: solid #black 10px;
background: url('img/bg.png') repeat;
}
body {
width: #8col;
margin: 0px auto;
padding: 100px 48px 84px;
background: #white;
color: rgb(60,60,60);
-webkit-text-size-adjust: 100%; /* Stops Mobile Safari from auto-adjusting font-sizes */
font: 13px/20px 'OftenRegular';
-webkit-tap-highlight-color: #green;
}
I've tried using height: 100% both for the body and html objects, but here's how it looks live: http://prikonline.be/prikactie/
How should I stick the border to the bottom of the page?
You could instead use a footer wrapper like this.
.footer {
position: absolute;
bottom: 0;
border-bottom: solid #black 10px;
width: 100%;
}
and just insert this right before </body> or somehting
<div class="footer"></div>
You can use position:fixed; and bottom:0px; to always, regardless of your scrolling state and content height, fix it to the bottom.
Try changing it to:
height:auto;
for your HTML CSS.
Hmmm... Putting min-height: 100% on the html element on your page (manipulating in Web Inspector) worked for me right away in Chrome; what are you testing in?
This approach does, however, go a little bit over 100% because of the height of the border, which you can correct for in IE8+/Gecko/WebKit with the CSS box-sizing property (use the value border-box).
For IE7 and IE6, if you care to make them render the same, it'd be pretty easy to write a little JavaScript that, on load or on resize, checks the window height, compares to document height, and if necessary forces the HTML element to the window height minus 20.
It looks like you're using some sort of dynamic stylesheet tool (like LESS). Usually the dynamic stylesheet tools let you use JavaScript. So you could define height as:
#height: `window.innerHeight + 'px'`;
And then add something like
body{
...
min-height: #height;
}
Of course, the problem with this is that if the user were to resize his/her browser window, the layout would not update appropriately. You could use the window.onresize callback to handle that.
Of course, you could use JavaScript to handle the whole thing. Granted, some vehemently oppose the use of JavaScript to do styling (separation of behavior, content, and style), when attempting things like a sticky footer, sometimes its easier to just write two lines of JavaScript than to try to come up with some clever CSS that may or may not work in every browser you're trying to target. If the user has JavaScript turned off, then the page just doesn't fill the whole height of the page on pages with less content.
window.onload = window.onresize = function(){
document.body.style.minHeight = (window.innerHeight-204) + "px";
// -4px for the border
// -200px for the padding on your body element
}
I do not advise you to apply CSS to html element. Instead create div with similar styles.
In general case your code sould be like this:
HTML
<div id="wrapper">
<!-- main content goes here -->
<div class="reserveSpace"></div>
</div><!-- #wrapper end -->
<div id="footer"></div>
CSS
* { margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; }
#wrapper { min-height: 100%; height: auto !important; height: 100%; }
#wrapper .reserveSpace { height: 100px; /* equals to footer height */ }
#footer { height: 100px; margin: -100px auto 0; background: #3CF; }
This works perfect in all browsers, even in IE6 :)
You can always implement this working sticky-footer CSS (I've added with inline social bar):
.sticky-bar {
background: #000000;
bottom: 0;
color: #D3D3D3;
font-weight: 300;
left: 0;
margin: 0;
opacity: 0.9;
padding: 0em;
position: fixed;
width: 100%;
z-index:99999;}
.sticky-bar-inner {
margin:0 auto;
text-align: center;
width:100%;
background-color: #D3D3D3;
padding: 3px;
font-family: 'Roboto', sans-serif;
font-size: 11px;
color: #000000;
}
.sticky-bar-inner p {
margin:0 auto;
padding: 3px;
text-align: center;
width:100%;
font-size: 11px;
}
#footerlist {
padding-left:0;
}
#footerlist li {
display: inline;
list-style-type: none;
}
HTML:
<!-- Footer -->
<div class="sticky-bar">
<div class="sticky-bar-inner">
<p>©2015 The astrobox.io Project<p>
<ul id="footerlist">
<li class="social"><img src="#" height="42" width="42"></img></li>
<li class="social"><img src="#" height="42" width="42"></img></li>
<li class="social"><img src="#" height="42" width="42"></img></li>
</ul>
</div>
</div>
Just edit the hrefs to your own personal urls, and the image src to the social style images you want (or include the font awesome package if you have it).
Here is how I added a body border at the bottom:
body {
box-sizing: border-box;
min-height: 100vh;
margin: 0;
border-bottom: solid 5px #ad3127;
padding-top: 1px;
}
<p>content</p>
The key is min-height: 100vh, which ensures that body height will at least be height of the viewport. Because of box-sizing: border-box, border of the body will be accounted in the body height. There is still a problem of content margins pushing the border below viewport, but that can be fixed with an arbitrary padding-top value.
Related
Firstly, I wanted to thank all of the great folks here who helped me solve a ton of issues with my basic layout, syntax, and the like. I think I have cleaned up my syntax and the development of my CSS as well as HTML are coming along quite nicely now.
Now, on to the issues at hand. There are two that I'm working through now:
There is spacing between the top navigation area, and the image in the next div. This only shows up at certain zoom levels, but I need to make sure it doesn't ever show up. I have tried eliminating the white space, and have made sure that all borders/padding are gone from this classes. The one thing I haven't tried is negative margins on the bottom of the Nav divs, but I would really like to do this without 'hacking' it with negative margins.
BONUS: Why can I not get the topImage class (which holds the .png file under the nav) to be an actual 100% width? I have tweaked it a bunch, but I keep ending up with padding on the sides. It's not the end of the world, but I would like it to be 100% just so it flows with the top elements, and also looks a little cleaner when it connects up to .bodySection2 and the .section divs that are the orange boxes.
This one is kind of annoying. I have a class, .section, which is the orange blocks on the page. These are all the same, programatically and I did a bunch of fiddling with the width and spacing to get them perfectly centered within the .bodySection2 div, so that I'm happy with. However, as you can see in the screenshot below, each of the boxes is a different size, even though they've been given the same Height % from the CSS. I realize that if I filled it out with text, they would adjust to be the same size, but I want to make sure they are the same size, regardless of the content inside of them. I have tried the Height: XX% (as well as making sure all parents have a % height set), but it does not seem to have any effect at all. Can you guys guide me on this one?
Fiddle HEre: Fiddle Here
Also - Any suggestions, advice, thoughts, comments, etc etc on the layout, color scheme, navigation elements, or whatever, would be greatly appreciated! I am in the midst of re-branding my company, and obviously, the web site is one of the biggest things to promote my brand.
HTML :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="keywords" content="">
<title>Frick Solutions - Technology Consulting for Small Business</title>
<meta name="keywords" content="HTML,CSS"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="/redesign/css/fricksolutions.css"/>
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto">
</head>
<body>
<div class ="container">
<div class="navLogo">
<img src="/redesign/img/FrickSolutionsLogoWhite.png" style="height:100%; width:AUTO;">
<div class="navElements" align="right">
<li> Why Us?</li>
<li> Small Business</li>
<li> Servers </li>
<li> #Home </li>
<li> Contact </li>
</div> <!--Close navElememts div -->
</div> <!--Close navlogo div -->
<div class = "bodySection">
<div class = "topImage">
<img src ="/redesign/img/NoteBookCoffeeforWeb2.png" style="width: 100%; height:auto; display:block;" alt="Let's Get to Work!">
</div> <!--Close TopImage div>\-->
</div><div class = "bodySection2"> <!-- close bodySection -->
<center>
<div class = "section" style="height:50%;">
<img src="/redesign/img/target.png"><br>
<b>A Targeted Approach</b><br>
Frick Solutions takes a targeted approach to solving your business problems through creative use of technologies.
</div><!-- Close leftSection -->
<div class = "section" style="height:50%;">
<img src="/redesign/img/arrow.png"><br>
<b>Guidance</b><br>
Providing guidance to small businesses on hot to get the best return on their technology investment and plan for the future.
</div> <!-- Close midSection -->
<div class = "section" style="height:50%;">
<img src="/redesign/img/speechbub.png"><br>
<b>Training</b><br>
Training for all of your staff on various technologies.</div>
</center>
<!-- Close rightSection -->
<!-- <div class = "section">
left text test
</div><!-- Close leftSection -->
<!--<div class = "section">
mid text test
</div> <!-- Close midSection -->
<!--<div class = "section">
right text test
</div><!-- Close rightSection -->
</center>
</div> <!--close bodySection2 -->
</div> <!-- close container -->
</body>
</html>
CSS:
body {
color: black;
font-family: "Roboto", sans-serif;
background-color: white;
margin: 0; /*use this to ensure left most content goes all the way to border of page */
width: 100%;
height: 100%;
}
html {
height: 100%; }
#media screen and (min-width:30em) { /* used to be 600 px */
.navLogo
{
padding-left: 1%;
padding-right: 1%;
position: fixed;
background-color: #373737;
width: 98%;
height: 10%;
/* border: 1px solid green; */
}
.navElements
{
padding-right: 1%;
padding-left: 1%;
font-family: "Roboto", sans-serif;
background-color: transparent;
position: absolute;
bottom: 0px;
width: 95%;
padding-bottom: .25%;
/* border: 1px solid orange; */
}
.navElements li
{
color: white;
background-color:transparent;
display: inline-block;
padding: 5px 10px 0 0;
}
a:link
{
color: white
}
a:visited
{
color: white
}
a:hover
{
color: grey;
}
.bodySection /* This is used to contain the image directly under the navigation/logo*/
{
padding-left: 1%;
padding-right: 1%;
padding-top: 5%; /*this is here as a hack to make sure the bodySection div shows up under the navLogo/navElement divs*/
width: 98%;
height: 100%;
overflow: auto; /*forces all content inside the div to appear within the div */
background-color: black;
display: block;
/* border: 1px solid red; */
}
.bodySection2 /*This holds the content under the images (boxes with images and text) */
{
padding-left: 1%;
padding-right: 1%;
padding-top: 1%;
width: 98%;
height: 100%;
overflow: auto; /*forces all content inside the div to appear within the div */
background-color: white;
display: block;
/* border: 1px solid red; */
}
.topImage
{
clear:left;
width: 100%;
display: block;
background-color: black;
overflow: auto;
/*border: 1px solid pink; */
}
.section
{
width: 22%;
height: 90%;
border: 4px solid;
border-color: #FFB238;
margin-left: 5%;
margin-right: 2%;
float:left;
padding-left: 1%;
padding-right: 1%;
margin-top: 1%;
padding-top: 1%;
padding-bottom: 1%;
margin-bottom: 1%;
/*overflow: auto; */
}
.container
{
width: 100%;
/*overflow: auto; */
background-color: black;
/*border: 1px solid blue; */
}
} /*closes # mediaedia screen and (min-width:30em */
User's Dorvalla and user112344 had the right idea. The only missing fix was the black space at the top of .bodySection. What was causing this issue was that padding-top: 5% (from .bodySection) and height: 10% (from .navLogo) are two very different things. The height in .navLogo is based of the the viewport, since .navLogo is a fixed element. On the other hand .bodySection's padding-top when used as a percentage is based on the width of the element. This is by design. According to the box-model spec:
<percentage>
The percentage is calculated with respect to the width of the generated box's containing block. Note that this is true for 'margin-top' and 'margin-bottom' as well. If the containing block's width depends on this element, then the resulting layout is undefined in CSS 2.1.
An easy way around this (for your case) is to use viewport units instead (don't worry, they are liquid). This coupled with removing your padding-left: 1% and padding-right: 1% from .bodySection fixes the other issue with your .topImage (technically you can remove your side padding on .bodySection2 as well).
For your .section height using flexbox works great to get them to be the same height. Just add display: flex and justify-content: space-around to .bodySection2 and remove your height on .section and they will happily comply to your wishes. Just make sure you don't forget the prefixes (-webkit- for Safari and -ms- for IE9).
* {
/* A quick css reset */
margin: 0;
padding: 0;
}
body {
font-family: "Roboto", sans-serif;
}
#media screen and (min-width:30em) {
.navLogo {
padding-left: 1%;
padding-right: 1%;
position: fixed;
background-color: #373737;
width: 98%;
height: 10%;
}
.navElements {
padding: 0 1%;
position: absolute;
bottom: 0;
right: 0;
padding-bottom: .25%;
}
.navElements li {
color: white;
display: inline-block;
margin-right: 10px;
}
a:link, a:visited {
color: white
}
a:hover {
color: grey;
}
.bodySection
{
/* Makes the padding equal to .navLogo's height */
padding-top: 10vh;
/* Removed padding-left and padding-right */
}
.bodySection2
{
margin: 2% 0;
/* Makes the .section's height match */
display: flex;
justify-content: space-around;
}
.section {
/* Removed height: 90% */
width: 22%;
border: 4px solid #FFB238;
padding: 1%;
text-align: center;
}
}
<body>
<div class="container">
<div class="navLogo">
<img src="http://www.fricksolutions.com/redesign/img/FrickSolutionsLogoWhite.png" style="height:100%;">
<div class="navElements">
<li>Why Us?</li>
<li>Small Business</li>
<li> Servers </li>
<li> #Home </li>
<li>Contact</li>
</div>
</div>
<div class="bodySection">
<div class="topImage">
<img src="http://www.fricksolutions.com/redesign/img/NoteBookCoffeeforWeb2.png" style="width: 100%;" alt="Let's Get to Work!">
</div>
</div>
<div class="bodySection2">
<div class="section">
<img src="http://www.fricksolutions.com/redesign/img/target.png">
<br>
<b>A Targeted Approach</b>
<br> Frick Solutions takes a targeted approach to solving your business problems through creative use of technologies.
</div>
<div class="section">
<img src="http://www.fricksolutions.com/redesign/img/arrow.png">
<br>
<b>Guidance</b>
<br> Providing guidance to small businesses on hot to get the best return on their technology investment and plan for the future.
</div>
<div class="section">
<img src="http://www.fricksolutions.com/redesign/img/speechbub.png">
<br>
<b>Training</b>
<br> Training for all of your staff on various technologies.</div>
</div>
</div>
</body>
EDIT
In order to fix the squishing of the logo (which oddly only happens in Chrome—and Opera, but no on really uses Opera) you can use object-fit: contain and object-position: 0 0. These allow background-image like behavior, but don't use background image. Chris Coyier at css-tricks.com has a nice, short, and sweet article for both object-fit and object-position. All it takes is one added rule to your css:
#logo img {
object-fit: contain;
object-position: 0 0;
}
While support for these two properties aren't all that great, since they are fully supported by both Chrome and Opera (the only two that need them to fix the issue) it isn't that big of a deal.
I took a moment to remove some of your css that was not doing anything. If you were attached to it in any way feel free to add it back in. Any properties that could be combined, along with any deprecated code (center and align="right"), were also modified.
Also a few suggestions. It's typically a good idea to avoid inline styling. You may want to think about moving the few inline styles you have left (I removed a lot that weren't doing anything in the quick clean up I did).
In addition to inline styles you may want to look at the semantics of your html. For instance, your .section's are a prime candidate for some simple modifications.
This:
<div class="section">
<img src="http://www.fricksolutions.com/redesign/img/speechbub.png">
<br>
<b>Training</b>
<br> Training for all of your staff on various technologies.
</div>
Could easily be changed to this:
<section>
<img src="http://www.fricksolutions.com/redesign/img/speechbub.png">
<h3>Training</h3>
<p>Training for all of your staff on various technologies.</p>
</section>
Simply change your css to reflect the changes (remove the '.' in front of .section and make the h3 tag match your font-size) and you won't even be able to tell the difference, but your html now has meaning (and break tags shouldn't be used for positioning). There of course could be an argument made against using a heading tag (which do you use? An h1? An h6? Something in between?) since there are no other used in your site. Technically HTML5 doesn't care though it's "strongly encouraged to use headings of the appropriate rank ...." If that bothers you you can just use a p tag and use either strong or b inside, similar to what you are doing now.
Another simple semantic fix would be to change .navLogo, '.navElements', and .topImage can all be changed from div's to header, nav, and figure respectively. Also, .container can be completely removed. All of this affects the look of your site in no way, but adds even more meaning to your html while removing a pointless element (if container is there for an unseen reason then I apologize).
If you really want to try something crazy you could get rid of .bodySection and .bodySection2 and instead wrap .topImage and the .section's (or section's if you change them) in a main tag. Just add the css rules from .bodySection and .bodySection2 with the addition of flex-wrap: wrap to main, add back the width: 100% to .topImage and move the margin: 2% 0 from .bodySection2 to your .section's. This removes two non-meaningful tags and adds one semantic one. Not a big change, but it cleans it up a bit.
HTML:
<main>
<figure class="topImage">...</figure>
<section>...</section>
<section>...</section>
<section>...</section>
</main>
CSS:
main {
padding-top: 10vh;
display: flex;
justify-content: space-around;
flex-wrap: wrap;
}
.topImage {
width: 100%;
}
.section {
margin: 2% 0;
...
}
Just a few ideas. There's absolutely no need to do any of that.
You may consider using a CSS reset at the beginning of your style file for unwanted spaces like this:
html, body, div, img, p, ul, li, span { margin: 0; padding: 0 }
I'm making a fixed width (120px) website for old feature phones that don't respond to media queries. The width of the body won't change even when I've defined it as 120px. When I open the website on the phone, it shows a huge horizontal scroll bar showing me a lot of blank space on the right which I'm assuming is the body. In the screen shot attached, I've set background color of body to red so you can see the problem (I also had to blackout the content for client privacy).
I'm using the following code:
html {
width:120x;
margin-left:0px;
}
body{
width:120px;
font-family: arial;
font: arial;
margin-left: 0px;
max-width:120px;
}
I think you've a typo here:
html {
width:120x;
margin-left:0px;
}
The width should be 120px
Remove the typo:
html {
width: 120px;
margin-left: 0px;
}
I think you have to use un child to wrap your content with a max-width.
and tags don't allow to do what you want.
HTML
<div class="wrapper">
Your content goes here
</div>
CSS
html,
body {
margin: 0;
height: 100%;
}
.wrapper {
box-sizing: border-box;
position: relative;
padding: 20px;
width: 120px;
height: 100%;
font-size: 14px;
background-color: #d63b24;
color: #fff;
}
http://jsfiddle.net/vinzcelavi/1rx7yn57/
Try this
body {
min-width: 1024px;
}
Here's your fiddle: http://jsfiddle.net/enxRw/1/
Hi I've got a website up.
I'm a no0b but I learn fast and I learn as I go.
However in one of the pages...the footer has gone up too close to the header. I want the area between the header and the footer fixed. I've tried changing the height of the main content in css but it doesn't seem to work. The front main page is ok. It's the about me page I'm having difficulty with. I just want the space between the header and footer fixed regardless of what's between them.
I use:
#site_content {
width: 950px;
overflow: hidden;
margin: 10px auto 0 auto;
padding: 10px;
}
thanks for your help.
Hey just replace your footer code by the below code
CSS
footer {
width: 100%; /* make width 100% changes done*/
font: normal 100% arial, sans-serif;
padding: 50px 20px 5px 0;
text-align: right;
background: transparent;
position: fixed; /*changes done*/
bottom: 0; /*changes done*/
top: auto; /*changes done*/
text-align: center; /*changes done*/
}
Add this to your #footer selector in your CSS:
#footer {
position:absolute;
bottom:0;
}
You can get an idea about how to do it by inspecting this template from twitter bootstrap:
http://getbootstrap.com/2.3.2/examples/sticky-footer.html
BTW: Twitter Bootstap may result interesting to you (based on the screenshot you show).
I am using HTML and CSS.
I can't display all of my content in the middle of the screen for varying display sizes.
I have attempted to use % in place of PX but it's unsuitable for small screen size such as 800*600 pixels.
Also I have performed web searches but my lack of in-depth knowledge of HTML is hindering my progress.
my code is this:
<style type="text/css">
#Line5
{
color: #7B7BC0;
background-color: #7B7BC0;
border-width: 0px;
}
#wb_Text1
{
background-color: transparent;
border: 0px #8B8B00 solid;
padding: 0;
}
<body>
<hr id="Line5" align="center" style="position:relative;top:28px;width:803px;height:93px ;z-index:0;">
<div id="wb_Text1" style="position:absolute;left:406px;top:58px;width:308px;height:36px;text-align:center;z-index:1;">
<span style="color:#FFFFFF;font-family:Arial;font-size:32px;"><strong><em>SAMPLE TEXT</em></strong></span></div>
can someone correct this piece of code for me?
Don't know what your desired output is like. But check this out.
Click Here for Demo
<div id="wb_Text1">
<span class="head"><strong><em>SAMPLE TEXT</em></strong></span>
</div>
Here updated code and its working fine.
<div id="wb_Text1" style="position:relative;display:table;margin-left:auto;width:100%;height:36px;text-align:center;margin-right:auto;z-index:1;background-color: #7B7BC0;">
<span style="color:#FFFFFF;font-family:Arial;font-size:32px;"><strong><em>SAMPLE TEXT</em></strong></span></div>
Not clear about your question but I think Either of the examples below could work for you ;
if you want it to be standards compliant, use this in your stylesheet:
body {
text-align:center;
}
#mainContainer {
margin:0 auto;
}
the body thing makes it work in IE, the margin:0 auto; makes it center in most other browsers.
you might have to go in and reset some of your main containers to text-align:left; because the body text-align:center sometimes cascades down into the site content, but you can counteract that by adding
text-align:left;
to #mainContainer
Or,
There may be better methods, but this works in all browsers so far :
body {width: /*fixed width or percentage here*/; height: auto; margin: 0 auto; padding: 0; background: #; color: #; font: ; text-align: center;}
or set body width to 100% and then just make a container div for your page
#container {width: /*fixed width or percentage here*/; height: auto; margin: 0 auto; padding: 0; background: #; color: #; font: ; text-align: center;}
Also not quite sure what you're asking for. I'm interpreting it as you wanting the div to be centered vertically and horizontally, so that's what I'm going for.
HTML
<div id="wb_Text1">
<b>SAMPLE TEXT</b>
</div>
CSS
body {
height: 100%;
width: 100%; //these two are so that the automatic margins work for the div.
}
#wb_Text1 {
height: 93px; //or whatever height you want
width: 300px; //or whatever width you want (can be in %)
background-color: #7B7BC0;
border: 0px;
padding: 0px;
font: 32px Arial;
line-height: 93px; //should be same as the height if you've only got one line of text and you want it vertically centered in the div
color: #fff;
text-align:center;
margin: calc(0.5 * (50% - 46.5px)) auto; //first value makes it vertically centered, the second makes it horizontally centered.
margin: -webkit-calc(0.5 * (50% - 46.5px)) auto; //for Safari
}
Here's what's happening inside the calc():
50% gives you half the total height of the page,
46.5px is half of the div's height, which in this case is 93,
50% - 46.5px gives you the amount of space needed to center the div vertically
Fiddle here: http://jsfiddle.net/Shiazure/hA9KB/
i thank all those who helped me. Problem was solved by adding the following code.
<style type="text/css">
div#container
{
width: 990px;
position: relative;
margin-top: 0px;
margin-left: auto;
margin-right: auto;
text-align: left;
}
....
.....
........
<body>
<div id="container">
...
....
Thank you so much that help a rookie !
I'm using Less Framework 4 for two websites I'm designing. In both designs I want to apply a 5 pixel border both on top and bottom of the document.
The problem: because of the styles applied to body, I'm applying the border-bottom and border-top to the html object, so the bottom border never sticks to the bottom of the page like it would happen in a usual sticky footer situation.
Here are the screenshots for the two cases:
Here's the (LESS) CSS I'm using for html and body: pastie.org/private/us5x1vhjnwzq6zsiycnu2g
html {
border-top: solid #black 10px;
border-bottom: solid #black 10px;
background: url('img/bg.png') repeat;
}
body {
width: #8col;
margin: 0px auto;
padding: 100px 48px 84px;
background: #white;
color: rgb(60,60,60);
-webkit-text-size-adjust: 100%; /* Stops Mobile Safari from auto-adjusting font-sizes */
font: 13px/20px 'OftenRegular';
-webkit-tap-highlight-color: #green;
}
I've tried using height: 100% both for the body and html objects, but here's how it looks live: http://prikonline.be/prikactie/
How should I stick the border to the bottom of the page?
You could instead use a footer wrapper like this.
.footer {
position: absolute;
bottom: 0;
border-bottom: solid #black 10px;
width: 100%;
}
and just insert this right before </body> or somehting
<div class="footer"></div>
You can use position:fixed; and bottom:0px; to always, regardless of your scrolling state and content height, fix it to the bottom.
Try changing it to:
height:auto;
for your HTML CSS.
Hmmm... Putting min-height: 100% on the html element on your page (manipulating in Web Inspector) worked for me right away in Chrome; what are you testing in?
This approach does, however, go a little bit over 100% because of the height of the border, which you can correct for in IE8+/Gecko/WebKit with the CSS box-sizing property (use the value border-box).
For IE7 and IE6, if you care to make them render the same, it'd be pretty easy to write a little JavaScript that, on load or on resize, checks the window height, compares to document height, and if necessary forces the HTML element to the window height minus 20.
It looks like you're using some sort of dynamic stylesheet tool (like LESS). Usually the dynamic stylesheet tools let you use JavaScript. So you could define height as:
#height: `window.innerHeight + 'px'`;
And then add something like
body{
...
min-height: #height;
}
Of course, the problem with this is that if the user were to resize his/her browser window, the layout would not update appropriately. You could use the window.onresize callback to handle that.
Of course, you could use JavaScript to handle the whole thing. Granted, some vehemently oppose the use of JavaScript to do styling (separation of behavior, content, and style), when attempting things like a sticky footer, sometimes its easier to just write two lines of JavaScript than to try to come up with some clever CSS that may or may not work in every browser you're trying to target. If the user has JavaScript turned off, then the page just doesn't fill the whole height of the page on pages with less content.
window.onload = window.onresize = function(){
document.body.style.minHeight = (window.innerHeight-204) + "px";
// -4px for the border
// -200px for the padding on your body element
}
I do not advise you to apply CSS to html element. Instead create div with similar styles.
In general case your code sould be like this:
HTML
<div id="wrapper">
<!-- main content goes here -->
<div class="reserveSpace"></div>
</div><!-- #wrapper end -->
<div id="footer"></div>
CSS
* { margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; }
#wrapper { min-height: 100%; height: auto !important; height: 100%; }
#wrapper .reserveSpace { height: 100px; /* equals to footer height */ }
#footer { height: 100px; margin: -100px auto 0; background: #3CF; }
This works perfect in all browsers, even in IE6 :)
You can always implement this working sticky-footer CSS (I've added with inline social bar):
.sticky-bar {
background: #000000;
bottom: 0;
color: #D3D3D3;
font-weight: 300;
left: 0;
margin: 0;
opacity: 0.9;
padding: 0em;
position: fixed;
width: 100%;
z-index:99999;}
.sticky-bar-inner {
margin:0 auto;
text-align: center;
width:100%;
background-color: #D3D3D3;
padding: 3px;
font-family: 'Roboto', sans-serif;
font-size: 11px;
color: #000000;
}
.sticky-bar-inner p {
margin:0 auto;
padding: 3px;
text-align: center;
width:100%;
font-size: 11px;
}
#footerlist {
padding-left:0;
}
#footerlist li {
display: inline;
list-style-type: none;
}
HTML:
<!-- Footer -->
<div class="sticky-bar">
<div class="sticky-bar-inner">
<p>©2015 The astrobox.io Project<p>
<ul id="footerlist">
<li class="social"><img src="#" height="42" width="42"></img></li>
<li class="social"><img src="#" height="42" width="42"></img></li>
<li class="social"><img src="#" height="42" width="42"></img></li>
</ul>
</div>
</div>
Just edit the hrefs to your own personal urls, and the image src to the social style images you want (or include the font awesome package if you have it).
Here is how I added a body border at the bottom:
body {
box-sizing: border-box;
min-height: 100vh;
margin: 0;
border-bottom: solid 5px #ad3127;
padding-top: 1px;
}
<p>content</p>
The key is min-height: 100vh, which ensures that body height will at least be height of the viewport. Because of box-sizing: border-box, border of the body will be accounted in the body height. There is still a problem of content margins pushing the border below viewport, but that can be fixed with an arbitrary padding-top value.