Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filling the available space with display:table-cell

Is it possible to avail the second div to occupy the available space of the parent div without specifying manual width?

Here is the Fiddle for the tried demo.

.right_cnt {
    display: table-cell;
    background:#FFC;
}

NOTE: I need yellow box to occupy the available right space.

like image 668
Sowmya Avatar asked Feb 27 '13 09:02

Sowmya


People also ask

How do you fit content in a table cell?

In "Table Tools" click the [Layout] tab > locate the "Cell Size" group and choose from of the following options: To fit the columns to the text (or page margins if cells are empty), click [AutoFit] > select "AutoFit Contents." To fit the table to the text, click [AutoFit] > select "AutoFit Window."

How do you put a space between a table and a div?

Make a new div with whatever name (I will just use table-split) and give it a width, without adding content to it, while placing it between necessary divs that need to be separated. You can add whatever width you find necessary.

How do you make a full width occupy table?

You need to set the margin of the body to 0 for the table to stretch the full width. Alternatively, you can set the margin of the table to a negative number as well.


2 Answers

Set display:table; width: 100%; on the parent element, remove float: left from the sibling. http://jsfiddle.net/byNpM/2/

like image 163
Tetaxa Avatar answered Sep 24 '22 02:09

Tetaxa


It is possible to use table layout to do this, but it's not necessarily the easiest way: forked your fiddle to demonstrate.

An easier way is to modify the second cell to remove all table display properties and set the second element's overflow to hidden: another fork demonstrating this. zoom: 1 allows the technique to work in old IE. This might be simpler for your purposes, if you're happy with the side-effects of the overflow

like image 25
Barney Avatar answered Sep 23 '22 02:09

Barney