jef*_*kee 42 html css html-table reset
看看这个例子:
而"规格"下的红色表并没有成为包含它的全宽 - 在Firebug上检查时,div不是220像素,而是基于内容宽度超过100个像素.
<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>
Run Code Online (Sandbox Code Playgroud)
CSS代码如下所示:
#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%;
}
Run Code Online (Sandbox Code Playgroud)
我知道有一个通用的CSS重置器,我认为这是导致问题的原因.不幸的是,我不能去除它的引用,因为此时多个站点从同一位置引用它,我不能在没有仔细审查的情况下进行更改.所以我需要一种方法来在样式表本身上覆盖它.调用的重置CSS是:
<link rel="stylesheet" type="text/css" media="all" href="http://demo.brixwork.com/master/css/reset.css" />
Run Code Online (Sandbox Code Playgroud)
Aat*_*ooq 101
你应该添加
display: table;
Run Code Online (Sandbox Code Playgroud)
在这个选择器下:
#listing_specs table { }
Run Code Online (Sandbox Code Playgroud)
该表继承了display:inline;
它应该是:display:table;
显示显示的部分:内联是:
.grid_1, .grid_2, .grid_3, .grid_4,
.grid_5, .grid_6, .grid_7, .grid_8,
.grid_9, .grid_10, .grid_11, .grid_12,
.grid_13, .grid_14, .grid_15, .grid_16 {
display: inline;
float: left;
position: relative;
margin-left: 10px;
margin-right: 10px;
}
Run Code Online (Sandbox Code Playgroud)