{"id":3051,"date":"2017-03-19T20:06:23","date_gmt":"2017-03-20T01:06:23","guid":{"rendered":"http:\/\/cssnewbie.com\/?p=2183"},"modified":"2017-03-19T20:06:23","modified_gmt":"2017-03-20T01:06:23","slug":"creating-a-footer-that-sticks-to-the-bottom-of-the-viewport","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/creating-a-footer-that-sticks-to-the-bottom-of-the-viewport\/","title":{"rendered":"Creating a Footer that Sticks to the Bottom of the Viewport"},"content":{"rendered":"<p>Creating a sticky footer (one that sticks to the bottom of the screen or viewport no matter what) is something that seems like it would be simple to achieve, but actually can be kind of a nuisance. The issue with footers is that sometimes if your page doesn&#8217;t have a lot of content and doesn&#8217;t take up the whole length of a page, the footer will just fall at the end of the content, rather than at the bottom of the viewport. Many developers struggle with finding a quick or easy fix for this issue, and if you&#8217;re one of them, you might want to try out the code that <a href=\"http:\/\/www.cssstickyfooter.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Sticky Footer<\/a>\u00a0has prepared just for this situation. Sticky Footer&#8217;s code will make sure that your footer always stays put at the bottom of the screen.<\/p>\n<p>Visit the site for yourself to learn more, or grab the CSS and HTML here.<\/p>\n<p>The basic HTML is simple. Take this snippet and fill it in with\u00a0code that will make up the content of your page:<\/p>\n<pre>\n&lt;div id=\"wrap\"&gt;<\/pre>\n<pre>   &lt;div id=\"main\"&gt;<\/pre>\n<pre>   &lt;\/div&gt;<\/pre>\n<pre>&lt;\/div&gt;<\/pre>\n<pre>&lt;div id=\"footer\"&gt;<\/pre>\n<pre>&lt;\/div&gt;<\/pre>\n<p>Now for the CSS:<\/p>\n<pre>\/*  \nSticky Footer Solution\nby Steve Hatcher \nhttp:\/\/stever.ca\nhttp:\/\/www.cssstickyfooter.com\n*\/\n\n* {margin:0;padding:0;} \n\n\/* must declare 0 margins on everything, also for main layout components use padding, not \nvertical margins (top and bottom) to add spacing, else those margins get added to total height \nand your footer gets pushed down a bit more, creating vertical scroll bars in the browser *\/\n\nhtml, body {height: 100%;}\n\n#wrap {min-height: 100%;}\n\n#main {overflow:auto;\n\tpadding-bottom: 180px;}  \/* must be same height as the footer *\/\n\n#footer {position: relative;\n\tmargin-top: -180px; \/* negative value of footer height *\/\n\theight: 180px;\n\tclear:both;} \n\n\/*Opera Fix*\/\nbody:before {\/* thanks to Maleika (Kohoutec)*\/\ncontent:\"\";\nheight:100%;\nfloat:left;\nwidth:0;\nmargin-top:-32767px;\/* thank you Erik J - negate effect of float*\/\n}\n\n\n\n\/* IMPORTANT\n\nYou also need to include this conditional style in the &lt;head&gt; of your HTML file to feed this style to IE 6 and lower and 8 and higher.\n\n&lt;!--[if !IE 7]&gt;\n\t&lt;style type=\"text\/css\"&gt;\n\t\t#wrap {display:table;height:100%}\n\t&lt;\/style&gt;\n&lt;![endif]--&gt;\n\n*\/<\/pre>\n<p>The CSS works by playing around with margins, padding, heights, and floats. It also includes some fixes for certain browsers that don&#8217;t work well with particular CSS properties. Also &#8212; don&#8217;t forget to include the conditional style in between the &lt;head&gt; tags of your HTML file so that if your page is viewed on Internet Explore 6 or lower, the code will still work.<\/p>\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Creating a sticky footer (one that sticks to the bottom of the screen or viewport no matter what) is something that seems like it would be simple to achieve, but actually can be kind of a nuisance. The issue with [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/creating-a-footer-that-sticks-to-the-bottom-of-the-viewport\/\" title=\"Click to read 'Creating a Footer that Sticks to the Bottom of the Viewport'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[172],"tags":[],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/3051"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=3051"}],"version-history":[{"count":0,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/3051\/revisions"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=3051"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=3051"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=3051"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}