I’m writing a page that looks code wise like
<div class="green">
<span class="orange">s1</span>
<span class="orange">s2</span>
</div>
but that should be formated via CSS like:

- The surrounding black frame shows the full page in the browser. (Think of
<body></body>) - The red frame is a fixed width and fixed hight basically empty space that should be added by the CSS
.green:before(I’m using it’s ability to format it’s borders for a visual effect) - The green frame shows the real content that should be as wide as necessary to contain both
<span>in one line - The blue frame should be created by the CSS
.green:after, has a fixed height and should take up all the space till the right border of the page – i.e. it must have a variable width.
Required browsers are the modern ones (Firefox, Chrome, Safari, Opera) in recent versions. No need to take care of IE. Mobile browsers would be great, though.
How can I achieve that? (All my attempts failed sooner or later…)
A jsFiddle with this example code is at http://jsfiddle.net/X2MDG/
I’m afraid that there is no way to satisfy all your constraints. The main things that don’t seem to have a CSS solution are:
:beforeand blue:aftercontent. As you mention in the comments to the question, using a different DOM structure is not an option.:after) content should take up all space not needed by the green (main) content.So, as far as I could tell, the question as you asked it doesn’t have a 100% satisfying answer. Either way, here’s the code I came up with researching this problem, perhaps it can help you or others stumbling on this question. See either this jsfiddle or the code below:
CSS: