I’m trying to have a column aligned left and then two rows to the right of it in a table like in my picture. Red and blue boxes are both supposed to be 50% of the height and 60% of the width. (sorry about the crude photo, Photoshop bugged out on me and paint isn’t my forte)
I’ve tried to create the table but can only seem to get it in rows.
Also in one of the boxes I have text that I want to be on the bottom of the table. I’ve tried to achieve this using vertical-align:bottom;
but I’m not sure if this is the best way to achieve this.
I understand this is a simple question but can’t wrap my head about it.
Here is my fiddle:http://jsfiddle.net/DPMC87/fmx9o2a2/
4
Answers
No need for tables or even flexbox for this layout! You can accomplish it using a few floats, and it still remains fully responsive.
Here is a screenshot of the final result:
And here is a live demo of the code that produces that result:
JSFiddle Version: https://jsfiddle.net/229zjpj7/
Table layout is also a good way to accomplish what you want.
but i would prefer using float property.
Yes we have used fixed height for blocks now , in my code it is 200px, and using fixed height for it is not a good option.
i would write small JS, for it to calculate height itself. or may be same height js for both columns.
HTML
CSS
here is a link to fiddle. http://jsfiddle.net/fmx9o2a2/6/
No need for floats to do this!
You can do this with flexbox.
There are a few benefits to going with flexbox over floats:
The key is setting the
.right
div to having 1.5 times the width of the.left
div. This will give it 60% of the width.Use
flex-direction: column
to allow the red and blue cells to take up 50% of the height of the container, no matter how tall it is.Here is a great source of info on flexbox. In some ways I think that flexbox is a step above floats, which were a step above table-based layout.
The explanation is in the table.