Tuesday, August 24. 2010Is it really that hard ...? (or how i finally learned to hate CSS)Trackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
that's pretty simple to solve with pure CSS ! #ALLDIV{position:absolute;width:100%;height:100%;} #TOP{position:relative;width:100%;height:30%;} #MAPS{position:relative;width:100%;height:70%;} and That's all folks, no need to troll 'bout the good ol dayz .... @T1B0: have you read up to my "PS:"? a static split is exactly *not* what i wanted to avoid This is actually pretty easy with a combination of CSS and javascript without using any sort of resize event capturing. You can use absolute positioning in css to position the map's bottom edge to 0, then use JS to get the height of the text div and set the map div's top attribute to that. Here's my CSS: And my JS (I used jquery for simplicity's sake, but it wouldn't be hard to write it in pure js) function resizeMap(){ I made the resizing a function in case it needs to be called again, but in Firefox I didn't see any issues in scaling up the text. I hope this helps! I probably should mention that the advantage to this approach as opposed to the CSS percentages is the lack of wasted space. Because the top of the #map element is determined in JS after the page loads, and the bottom is statically set to 0, the map cannot drop below the bottom of the page. I'm not sure how this will affect your maps, but divs filled with text are acting fine. The only time a scrollbar is created is when actual content is being cut off. If the map itself needs to be resized there should still be a solution to this problem. This will be my last comment - I promise I went and looked at this openlayers thing, and played around with the code. I saw a bit of a problem when the map wouldn't load because there was no explicit height set on #map in the CSS. The solution to this is to get the computed height of the div, and set it to that. That will convince the map to load, but be ignored by the browser when creating the box for the map, allowing for resizing and no capturing events. So as not to ridiculously enlarge the comments section agai, I've put the full code on pastebin. You can view it here: http://pastebin.com/GumWwSMB PS: Don't hate CSS, it's your friend! Thanks Anthony, that works as intended indeed ... I'll continue to claim that CSS is a mess though, it should have something like "height: auto-as-small-as-possible" and "...: auto-as-large-as-possible" instead of having to fall back to custom JS code for this ... You don't have to resort to JavaScript, if you're willing to put up with a little extra markup. All you need is the oft-overlooked CSS tables (well, in browsers that support it--so not IE6 or IE7). On second thought, since it took me a bit of playing, I went ahead and threw up an example on my little corner of the 'net. heheeh so very true! I had the same awakening few years ago when i though i would learn the proper way of using css instead of hacking this or that in nasty way ..... i got 2 books on css and guess what! they both said you need hacks to do the simplest 3 col layout. There is just no proper way to work with css as i see it. I manage to do what i need but even now css is still annoying. |
Calendar
QuicksearchArchivesCategoriesBlog AdministrationChoose LanguageShow tagged entries |
|||||||||||||||||||||||||||||||||||||||||||||||||