Search code examples
htmlcsscss-tables

How can I wrap the table (CSS)


Red: Window
Black: table

How to change the CSS make the green and blue div wrap the table?

*do not change the width of div

enter image description here

Live: http://jsfiddle.net/losiuhoi/xvV8E/


Solution

  • You shouldn't specify the width of the wrapping divs (and put them inline-block):

    .green{
        display: inline-block;
        height:200px;
        background-color:#0C0;
    }
    

    If you DO specify the width (like 98%) in your example, it won't wrap the table fully but only 98% of it.

    Thanks to Paulie, here is a JSfiddle : http://jsfiddle.net/Paulie_D/xvV8E/5/

    Also, display: table; would work as well, you have to chose which one is the most semantically correct i guess, if there is no other difference in behavior.