carpat
carpat

Reputation: 871

Is it possible to have a parent element size itself based on a child element min-width?

I have a parent element with some child elements. The child elements have a min-width set, but the parent does not. When the browser window is smaller than the min-width, the child elements are the correct width, but the parent keeps getting smaller, causing the children to overflow. Is it possible to force the parent to be at least as wide as the children? (without using javascript)

http://jsfiddle.net/Psczr/

(drag divider most of the way to the right and then scroll right in the result window)

Upvotes: 1

Views: 1381

Answers (2)

Memos Electron
Memos Electron

Reputation: 660

Set the min-width on the parent and on the child inherit ... but the parent of the td in your script is not the div but the tr ... the parent of the tr is the table ... and the parent of the table is the div.

http://jsfiddle.net/Psczr/12/

Upvotes: 2

mikeswright49
mikeswright49

Reputation: 3416

Your issue in this situation is that you're using a relative width for the parent and a fixed min width for the children. The solution you're trying to handle is not possible in straight CSS. You should instead use relative widths for all elements or establish a fixed min width for the parent.

Upvotes: 1

Related Questions