jquery - Background image covering browser window minus header and footer below the fold -


title might bit confusing, i'll try best explain need achieve. have following elements particular webpage:

  1. header - visible above content
  2. content - background image covers entire content area - this key part
  3. sub-footer - information content visible below it
  4. footer - standard company footer, visible if window height size, otherwise need scroll down see it

as mention above, content portion of page maybe trickiest part. need big image in background covers entire area. css-tricks has excellent guide in ways full page background images. i'm hoping can achieved easily. issue how make sub-footer stay @ bottom if window <720px footer underneath below fold (needing scroll it). window >720px should show both sub-footer , footer no scrollbars.

i won't worry @ point minimum height content needs (possibly necessitating scrollbars on content <div> or making both sub-footer and footer go below fold).

here image mockups of i'm trying achieve:

first - window <720px tall footer needs scrolled to: <720px tall window footer needs scrolled to

second - window <720px tall has been scrolled down see footer: enter image description here

finally - tall window >720px has no scrollbars because visible: enter image description here

i'm using jquery , don't care ie6. can achieve in css? have use jquery dynamically adjust things? full page backgrounds done css3, i'm happy use css3 or html5 need.

you can not use css position: fixed because relative viewport, not parent element.

what need have "subfooter" fixed positioned child element of "content". in order that, you're going have use javascript.

something should need. try changing height variable in css #content can see how behaves various content heights:

<html> <head> <script src="http://code.jquery.com/jquery-1.4.4.min.js"></script> <style>     #header {         height: 50px;         background-color: #ccc;         width: 100%;         margin-bottom: 10px;     }      #content {         position: relative;         height: 1500px;         width: 100%;         background-color: #ccc;     }      #subfooter {         height: 50px;         width: 100%;         background-color: #666;         position: fixed;     }      #footer {         height: 50px;         width: 100%;         margin-top: 10px;         background-color: #ccc;     } </style> <script>     $(document).ready(function(){          $(document).scroll(function() {             position_subfooter();         });          var position_subfooter = function() {             $("#subfooter").css("bottom", "20px");             if(($("#subfooter").offset().top - $("#subfooter").height()) > ($("#content").scrolltop() + $("#content").height())) {                 $("#subfooter").css("bottom", ($("#subfooter").offset().top - ($("#content").scrolltop() + $("#content").height()) + 20));             }         }         position_subfooter();     }); </script> </head> <body>     <div id="header">         <h1>header</h1>     </div>     <div id="content">      </div>     <div id="subfooter">         <h2>sub footer</h1>     </div>     <div id="footer">         <h1>footer</h1>     </div> </body> </html> 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -