Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tbody width not automatically extending to width of table

Take a look at this example here:

http://denise.brixwork.com/showlisting/1/8297-Valley-Drive-Alpine-Meadows-Whistler-denise-brown-real-estate

And the red tables under "Specifications" is not becoming the full width of the containing it - when inspecting on Firebug, the div is not 220 pixels, but rather, just over a 100 pixels based on the content width.

<div class="grid_4 alpha">     <table width="100%" class="grid_4 alpha omega">             <tr class="specrow">             <td class="specname">type:</td>             <td class="specvalue">House</td>         </tr>         <tr class="specrow">             <td class="specname">year:</td>             <td class="specvalue">1986</td>         </tr>     </table> </div> 

The CSS code looks like this:

#listing_specs table {     width: 100%; }  #listing_specs table tbody {     display: table-row-group;     width: 100%; }  .specrow {     margin:2px 0px;     border-bottom:1px dotted #dadada;     color: #fff;     width: 100%;     background-color: #A92229; }  .specrow:hover {     background-color:#fff;     color:#333; }  .specname{     font-weight: 600;     padding:2px 2px 2px 5px;     width: 50%;     white-space: nowrap; }  .specvalue {     font-weight:normal;     padding:2px 5px 2px 5px;     text-align:left;     width: 50%; } 

I know there is a generic CSS resetter, and I think that's what's causing the problem. Unfortunately I can't go and just remove the reference to it because multiple sites refer to it from the same location at this moment, and I can't just make that change without careful review. So I need a way to override it on the stylesheet itself. The reset CSS being called is:

<link rel="stylesheet" type="text/css" media="all" href="http://demo.brixwork.com/master/css/reset.css" /> 
like image 856
jeffkee Avatar asked Jul 03 '12 17:07

jeffkee


People also ask

How do you auto adjust table td width from the content?

remove all widths and add . content-loader table tr td { white-space: nowrap; } ? Since you have a fixed width for the container, you have too many fields inside of it to fit properly. If you had less it probably would have adjusted on its own.

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.

How fix TD table width?

By using CSS, the styling of HTML elements is easy to modify. To fix the width of td tag the nth-child CSS is used to set the property of specific columns(determined by the value of n) in each row of the table.

How fix HTML table width?

To set the table width in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <table> tag, with the CSS property width.


2 Answers

you should just add

display: table; 

under this selector:

#listing_specs table { } 
like image 96
Aatif Farooq Avatar answered Oct 21 '22 12:10

Aatif Farooq


You can use this code

tbody{     width: 100%;     display: table; } 
like image 31
Rostyslav Kulchytskyi Avatar answered Oct 21 '22 11:10

Rostyslav Kulchytskyi