html - Why won't my table column respect a max-width of 50%? -


i trying table column expand fill contents, until it's taking 50% (or arbitrary %) of width of whole table. i've set every cell in column, including header, have max-width: 50%; in css style.i've verified rule isn't being overridden max-width.

fixed pixel amounts max-width work fine. percents seem failing take effect.

i've tried simplifying reproducable example see if other obscure layout or css quirk causing problem, , i'm still able reproduce it.

jsfiddle: http://jsfiddle.net/8lmtvzur/1/

html:

<table class="data">     <thead>         <tr>             <th>entry header 1</th>             <th>entry header 2</th>             <th>entry header 3</th>             <th class="asdf">entry header 4</th>         </tr>     </thead>     <tbody>         <tr>             <td>entry first line 1</td>             <td>duis sollicitudin ipsum diam, cursus tristique lorem placerat.</td>             <td>entry first line 3</td>             <td class="asdf">entry first line 4</td>         </tr>         <tr>             <td>entry line 1</td>             <td>duis sollicitudin ipsum diam, cursus tristique lorem placerat.</td>             <td>entry line 3</td>             <td class="asdf">entry line 4</td>         </tr>         <tr>             <td>07/07/2014 11:51 am</td>             <td>duis sollicitudin ipsum diam, cursus tristique lorem placerat.</td>             <td>entry last line 3</td>             <td class="asdf">                 nullam consectetur pretium tristique. vestibulum facilisis dapibus vulputate. sed et arcu ac arcu pretium porttitor. nullam quis ante.<br/>                 <br/>                 donec @ condimentum nunc. maecenas in arcu ligula. etiam dictum metus massa, eu dignissim nibh tempor a. maecenas.<br/>                 <br/>                 donec ac turpis felis. sed blandit dignissim convallis. in hac habitasse platea dictumst. pellentesque pretium, sem ac pellentesque gravida, velit erat semper nisi, placerat posuere dui augue non nunc. curabitur id augue @ turpis vestibulum suscipit. suspendisse lacinia imperdiet metus sit amet lobortis. proin nec mi lectus. nam rutrum maximus felis quis congue. vivamus nec augue felis.             </td>         </tr>         <tr>             <td>03/18/2015 11:05 am</td>             <td></td>             <td>blah</td>             <td>testing 1 2 3 <br/>                 4 56</td>         </tr>     </tbody> </table> 

css:

table {     border-spacing: 0;     border-collapse: collapse; }  table tr td, table tr th {     font-size: 10.6667px;     font-family: osaka, verdana, sans-serif;     vertical-align: top;     border: 1px #dddddd solid;     padding: 2px; }  td.asdf, th.asdf {     max-width: 10%; } 

try using width instead:

http://jsfiddle.net/gd77gxcc/

max-width not defined in current standards table elements can't relied upon:


in css 2.1, effect of 'min-width' , 'max-width' on tables, inline tables, table cells, table columns, , column groups undefined.

http://www.w3.org/tr/css21/visudet.html#propdef-max-width


css 2.1 explicitly leaves behavior of max-width undefined. therefore behavior css2.1-compliant; newer css specifications may define behavior, web developers shouldn't rely on specific 1 now.

https://developer.mozilla.org/en/docs/web/css/max-width


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -