CSS Make one row the width of another

Posted by gav on Stack Overflow See other posts from Stack Overflow or by gav
Published on 2010-05-01T11:04:26Z Indexed on 2010/05/01 11:07 UTC
Read the original article Hit count: 290

Filed under:
|
|

I'm sure this is a fairly common problem but I'm new to CSS so I'm not sure how it's done. I tried searching for the issue but sometimes it's tricky to get the right keywords.

I have a table the width of which I want to be constrained by a specific row. My table css is as follows;

table {
    border: 1px solid #ccc;
    width: auto;
    margin-left: auto;
    margin-right: auto;
}

I have one row which contains cells for which I want the width to autofit and two rows of prose which currently force the table to take 100% width.

How do I constrain the latter to have at most the autofit width of the first row?

If tables aren't the way to go and this should be pure css and divs, how do you get one class to adopt the fixed but unknown width of another?

Thanks,

Gav

© Stack Overflow or respective owner

Related posts about css

Related posts about alignment