I'm trying to achieve a fixed width centred layout with headings that 'stretch' to the edge of the users browser. Like this...
Any ideas how I can achieve this?
I'm trying to achieve a fixed width centred layout with headings that 'stretch' to the edge of the users browser. Like this...
Any ideas how I can achieve this?
Maybe you could use an illusion to accomplish this? You can try having a blue bar with width = 100% sit behind all of your page content, such that it is only exposed to the right of the blue "sub-heading" section, but always reaches the right edge. You just have to make sure you eclipse the rest of it (anything to the left of the blue "sub-heading" element).
Here is my attempt using JavaScript, maintaining a fixed width center: Demo
Otherwise, I don't think what you want is possible using pure CSS, but I could be mistaken.
Perhaps this would work?
This works splendidly. It could use some refinements, but the idea is quite solid.
Live Demo (edit)
CSS:
HTML:
if you want be fixed in the window you can use
position:fixed
otherwiseposition:absolute
. Then withleft:0
andright:0
you position them in the left or right side. Usingtop
you can set the offset from top.Demo: http://jsbin.com/awoke3