Answer the question
In order to leave comments, you need to log in
CSS: fixed title in a full-width fluid block
To avoid wasting bytes on explanations, here's a sandbox stub: jsfiddle.net/RYCnH/
If you remove position:fixed; the header normally takes up the entire width, but goes up when scrolling. We want the .header block to take up the entire width of the .container block and remain visible on scroll.
Answer the question
In order to leave comments, you need to log in
A small javascript with jQuery:
I think this is about what you need :-)
$(document).ready(function(){
$(window).scroll(function(){
var header = $('.header').detach();
var scrollTop = $(window).scrollTop();
$('.container p').each(function(){
if ($(this).offset().top > scrollTop)
{
$(header).insertBefore(this);
header = null;
return false;
}
});
if (header)
{
$('.container').append(header);
}
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question