HTML / CSS: How to get fixed margin between body and footer -
i new css , trying set page there fixed margin / space between page's main content (sidebar / sections) , footer (e.g. 120px) should work cross-browser.
also, in case there little content on page footer should appear @ least @ bottom of (visible) screen.
i made multiple attempts applying class "footer"
, incl. following, margin ignored.
my html structure (simplified):
<!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- ... --> </head> <body> <nav> <!-- ... --> </nav> <section id="sidebar"> <!-- ... --> </section> <section id="main"> <!-- ... --> </section> <footer class="footer"> <div>some text</div> </footer> </body> </html>
my css:
.footer { color: #333; font-size: 11px; text-align: center; vertical-align: bottom } .footer:before { clear: both; display: block; height: 120px; min-height: 120px; }
can me ?
also, if should changed regarding html please let me know well.
many in advance, mike
this should help:
html, body { height: 100%; } body { margin:0px; padding: 0px; } .wrap { height: auto; margin: 0 auto -80px; /* footer height + space */ min-height: 100%; padding: 0 0 80px; /* footer height + space */ box-sizing: border-box; overflow: auto; } .footer { background-color: #111111; color: #eeeeee; border-top: 1px solid red; height: 60px; /* footer height */ padding-top: 20px; display: block; margin-top: 20px; /* space between content , footer */ box-sizing: border-box; position: relative; width: 100%; }
<body> <div class="wrap"> <nav> <!-- ... --> </nav> <section id="sidebar"> <!-- ... --> </section> <section id="main"> <!-- ... --> </section> </div> <footer class="footer"> <div>some text</div> </footer> </body>
Comments
Post a Comment