How to solve Repeated column in Grails mapping for entity?

Valid solution to the CSS equal height columns problem?

  • Is this a good way to solve the equal height columns problem in CSS? I was trying to solve the problem of how to get background colours to fill the full column heights in a three-column layout, as the shorter columns only extend far enough to cover their contents and so don't line up. Being a relative beginner at all this, I looked both in my web-design book and on the internet for how to go about it - and most advice seemed to be either for the faux-columns way, using repeated images, or the huge padding/negative margin overflow way, neither of which seemed ideal. Or other hacks of similar complexity. But then I thought of using two extra divs - one around the left and central columns, with the central column's own background-color set and the left column relying on the background-color of the extra div to show through its transparency, becoming its background. The containing div naturally extends to the height of the longest column, and so too does the background colour. Same with the larger div, taking care of the background colour of the right column. (brief outline of the HTML structure at Pastebin http://pastebin.com/m65b3c516) And with all the divs floated to the left (except possibly the centrecolumn floated to the right), that seems to have solved the problem. But while there have been many solutions suggested on the internet, I don't seem to see this one around - it seems to work really well with most browsers (although it took a little more work with IE6), and I got it to work for the website I'm building in both fixed and liquid layouts. (I used the #wrapper as the #rightcolumnbackground there, which meant I really only had to add one div.) Are there cons to this I'm not seeing? Or are the book and all the articles I read on this just out of date? What's the easiest way to solve the problem right now?

  • Answer:

    Yes, I think I see the overall div scheme. However, if you make the changes you describe, then the layout only works if the longest column is not the background div color. The layout won't work both ways; you have to pre-determine which column is longer. If this design is a template used by a CMS, you wouldn't get to change the layout on a case-by-case basis. Or am I misunderstanding?

dolca at Ask.Metafilter.Com Visit the source

Was this solution helpful to you?

Other answers

Hey dolca, if you're still checking this thread -- I don't know what browser you're using, but it doesn't seem quite right in Firefox 2.0 (I know a lot of people are using 3 now, but you might want to check both). Good luck!

amtho

If you're ok with doing a some hacky stuff to take care of IE6 and IE7, you can use http://www.onenaught.com/posts/201/use-css-displaytable-for-layout on your divs and everyone goes home happy. Except the 70% of people who use IE6 and IE7.

the jam

dolca: that is what is so elegant about the technique, as the #overlord div encompasses the three smaller divs, you make the background of #overload the three columns, and then repeat-x on the background, creating all three backgrounds in #overload. then the columns are positioned over their correct background, and column content length does not matter. http://www.neuroticweb.com/recursos/2-columns-layout/

zentrification

zentrification: as far as I can tell, that won't work with layouts where the table columns aren't a fixed width, will it?

amtho

dolca: I'm sorry to be so negative here, but absolutely knowing which column will be longest may not be that common. The real world, it so often puts a crimp in our more elegant solutions. But, yes, the basic concept seems OK.

amtho

zentrification: I think I understand your idea (isn't it the http://www.alistapart.com/articles/fauxcolumns/), and yeah, doesn't that only work with fixed-width columns? amtho: You're not being negative at all - it's the help I was looking for. But don't we often know which column will be longest? I mean, in the 3-column layout where two columns are support information and one is where most of the content is - isn't that a very common use of the 3-column? But I get what you're saying though - much like zentrification's solution, it only works under certain conditions.

dolca

I found http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks - haven't had time to try it yet, but looks like it should work even if you don't know which column is going to be the tallest?

dolca

http://ask.metafilter.com/116833/Valid-solution-to-the-CSS-equal-height-columns-problem#1675652 I tried Matthew James Taylor's solution on my page http://www.ira.myzen.co.uk/mjt/index.html, and it seems to work great - it doesn't matter now how tall any of the columns are or extend to. No images, no javascript, and should work in all the common browsers. It took the concept behind my idea much further - takes a little more maths, so if you know which column is tallest, my idea could still be more convenient - but if you don't, this pretty much solves it I think! What do people think? Any problems I'm not seeing?

dolca

Yeah, I even test in Netscape 3 and some old browsers that only run on Mac OS9. Also, it's really hard to test in older versions of IE (since you can only have one version installed at a time), but it's important.

amtho

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.