Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am trying to create a full-width header on a fixed-width page.
Question for the CSS experts out there: is there a trick, e.g. by using negative margins or something, to make the #header paggind stretch over on the sides the #page width?
Thanks.
Comments
Comment #1
Gabriel R. CreditAttribution: Gabriel R. commentedThis sort of works, but it adds an unwanted horizontal scroll bar:
If only `overflow-x` would work :-s
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedNo, this is definitelly not the way to go :)
More simply, do not hesitate to edit the page template and take the header out of the #page. As everything that is inside the #page is restricted to a width, taking the header out of it (so making the #page start with the #main) is going to free the header from the #page restrictions.
so it would be like this :
As a general rule, make the markup the way you want before tricking the css, css rules shouldn't have be too complicated ;)
Comment #3
Gabriel R. CreditAttribution: Gabriel R. commentedYeah, that's what I'll end up doing, but I think I actually seen the CSS-only method work somewhere. Just can't remember where.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedIf you realy want to keep the header unchanged in page tpl, the other way around would be to position the header absolutely, to take it out of the page flow, and then move the page down to the size of the header, like this :
#header { layout.css (line 101)
position:absolute;
left:0;
top:0;
width:100%;
}
#page { main.css (line 12)
margin-top:(-> header height);
}
Comment #5
Gabriel R. CreditAttribution: Gabriel R. commentedThanks. That makes sense.
I ended up just adding a BG image on the body instead of #header :-)
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commented