tags:

views:

74

answers:

4

Hey,

I want do do a layout that is search engine and speed-browser friendly with content first in source code. Usually this looks like this:

    <body>
    <div id="content" style="margin-top: 200px;">
    i am content, i go first
    </div>
    <div id="head" style="height: 200px; position: absolute;">
    i am an header that is depressed because my designer things i am not important
    </div>
    </body>

but I need an dynamic sized header increases the height with its content... this must be a common problem. is it possible to solve somehow? any ideas?

+1  A: 

I do not think this is possible using CSS alone. Need JavaScript.

babtek
in my particular case this might really be the way to go beacuse the header increases its height only by content loaded dynamically using xmlhttpget requests... so javascript can be taken for granted. however it would be interesting if theres another solution.. maby tables
Joe Hopfgartner
+1  A: 

As far as I am concerned it can only be achieved using tables.

<table>
    <tr>
        <td><!-- empty table cell --></td>
        <td rowspan="2" valign="top">General Content</td>
    </tr>
    <tr>
        <td valign="top">Navigation</td>
    </tr>
</table>
Nazariy
i thought about that too but didnt quite figure a way out! can you provide some sample code or tell me how you would do that? thanks.
Joe Hopfgartner
thanks! but still, cant get it to work.. http://jsfiddle.net/zfhmW/
Joe Hopfgartner
+1  A: 

I agree with @babtek though, I'd really like to be wrong, cause this looks interesting.

Also, this is probably not what you need, but HTML5 has a "reversed" attribute for <ol> that could do the trick.

vassilis
this looks interesting! might be an good option in combination with a no-javascript fallback!
Joe Hopfgartner
A: 

Since you've tagged the divs with id, it makes more sense to put the styles in css.

In any case, have you tried

height: auto; 

If you want to let the height adjust with content but have it at least 200px, then

min-height: 200px; 

should do the trick.

Marc Thibault
thanks for your input but i think you mis understood the question. the problem isnt the dynamic increasing but the source order of the content elements. the current solution to have a contnet-first order seem to only support fixed height headers.
Joe Hopfgartner