html - How to force a container element to the width of its widest child element using CSS? -



html - How to force a container element to the width of its widest child element using CSS? -

here simplified code of tabulated input form:

<html> <body> <div class='container' style='width: 950px; margin-left: auto; margin-right: auto'> <form> <table> <colgroup> <col width='175' /> <col width='200' /> <col width='200' /> </colgroup> <tr> <td>input field 1</td> <td>input field 2</td> <td>input field 3</td> </tr> </table> <div class='buttons-small' style='float: right';> <button class='submit'>update</button> <button class='cancel'>cancel</button> </div> <div style='clear: both'></div> </form> </div> </body> </html>

what buttons-small div align right border of table above it. can set width property form (in case 575px), table varying in width depending on columns selected php generating code. therefore, width of form needs dynamic. right inheriting width of container, presumably because right-floated buttons forcing to.

how can ensure form width of table within it, using css? means i've found far float left, seems un-necessary given no elements required right of it.

thanks!

add display: inline-block; form , shrink-wrap container around table.

html css

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -