【发布时间】:2016-05-02 12:52:38
【问题描述】:
我偶然发现了一个奇怪的问题。我正在用 CSS 设计一个表格。当我给 <td> 元素一个具有背景渐变和一些基本文本样式的类时,渐变效果非常好,但文本样式被完全忽略了。
当我从 CSS 类中删除文本样式并将其添加到带有 style="" 的内联 CSS 时,它工作得非常好!现在我不是设计师,所以我只是在某个地方错过了一些东西,但这对我来说似乎很奇怪。
相关CSS:
.top_td {
background:-o-linear-gradient(bottom, #001e5b 5%, #00153e 100%);
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #001e5b), color-stop(1, #00153e) );
background:-moz-linear-gradient( center top, #001e5b 5%, #00153e 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#001e5b", endColorstr="#00153e");
background: -o-linear-gradient(top,#001e5b,333333);background-color:#00153e;
text-align:center;
font-size:14px;
font-family:Verdana;
font-weight:bold;
color:#ffffff;
}
相关 HTML:
<tr>
<td class="top_td" style="">
<strong>WELKOM</strong>
</td>
<td class="top_td">
<strong>OPENINGSTIJDEN</strong>
</td>
<td class="top_td">
<strong>ADRES</strong>
</td>
</tr>
<tr>
<td class="top_td" style="text-align:center;font-size:14px;font-family:Verdana;font-weight:bold;color:#ffffff;">
<strong>INLINE CSS</strong>
</td>
<td class="top_td" style="text-align:center;font-size:14px;font-family:Verdana;font-weight:bold;color:#ffffff;">
<strong>WORKS</strong>
</td>
<td class="top_td" style="text-align:center;font-size:14px;font-family:Verdana;font-weight:bold;color:#ffffff;">
<strong>PERFECTLY FINE</strong>
</td>
</tr>
要自己查看结果,请查看代码 sn -p:
.TableDIV {
margin:0px;padding:0px;
width:100%;
-moz-border-radius-bottomleft:5px;
-webkit-border-bottom-left-radius:5px;
border-bottom-left-radius:5px;
-moz-border-radius-bottomright:5px;
-webkit-border-bottom-right-radius:5px;
border-bottom-right-radius:5px;
-moz-border-radius-topright:5px;
-webkit-border-top-right-radius:5px;
border-top-right-radius:5px;
-moz-border-radius-topleft:5px;
-webkit-border-top-left-radius:5px;
border-top-left-radius:5px;
}
.TableDIV table{
border-collapse: collapse;
border-spacing: 0;
width:100%;
height:100%;
margin:0px;padding:0px;
}
#top_table tr:last-child td:last-child {
-moz-border-radius-bottomright:5px;
-webkit-border-bottom-right-radius:5px;
border-bottom-right-radius:5px;
}
#top_table tr:first-child td:first-child {
-moz-border-radius-topleft:5px;
-webkit-border-top-left-radius:5px;
border-top-left-radius:5px;
}
#top_table tr:first-child td:last-child {
-moz-border-radius-topright:5px;
-webkit-border-top-right-radius:5px;
border-top-right-radius:5px;
}
#top_table tr:last-child td:first-child{
-moz-border-radius-bottomleft:5px;
-webkit-border-bottom-left-radius:5px;
border-bottom-left-radius:5px;
}
.TableDIV td{
vertical-align:middle;
text-align:left;
padding:0;margin:0;
font-size:10px;
font-family:Verdana;
font-weight:normal;
color:#000000;
}
.top_td {
background:-o-linear-gradient(bottom, #001e5b 5%, #00153e 100%);
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #001e5b), color-stop(1, #00153e) );
background:-moz-linear-gradient( center top, #001e5b 5%, #00153e 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#001e5b", endColorstr="#00153e");
background: -o-linear-gradient(top,#001e5b,333333);background-color:#00153e;
text-align:center;
font-size:14px;
font-family:Verdana;
font-weight:bold;
color:#ffffff;
}
<div class="TableDIV">
<table id="top_table">
<tr>
<td class="top_td" style="">
<strong>IN CSS</strong>
</td>
<td class="top_td">
<strong>FILE</strong>
</td>
<td class="top_td">
<strong>DOESN'T WORK</strong>
</td>
</tr>
<tr>
<td style="background: #777777;text-align:center;">
<img src="http://www.petervanderleegte.nl/images/IMG_6317.JPG" style="margin:0; padding:0; width: 130px;">
</td>
<td style="vertical-align: top;background: #777777;">
<table style="border-left: 1px solid #333; border-right: 1px solid #333;">
<tbody>
<tr style="background-color: #989898;">
<td>Maandag:</td>
<td style="font-style: italic;">08:00 - 17:00</td>
</tr>
<tr>
<td>Dinsdag:</td>
<td style="font-style: italic;">08:00 - 17:00</td>
</tr>
<tr style="background-color: #989898;">
<td>Woensdag:</td>
<td style="font-style: italic;">08:00 - 17:00</td>
</tr>
<tr>
<td>Donderdag:</td>
<td style="font-style: italic;">08:00 - 17:00</td>
</tr>
<tr style="background-color: #989898;">
<td>Vrijdag:</td>
<td style="font-style: italic;">08:00 - 17:00</td>
</tr>
<tr>
<td>Zaterdag:</td>
<td style="font-style: italic;">Op afspraak</td>
</tr>
<tr style="background-color: #989898;">
<td>Zondag:</td>
<td style="font-style: italic;">Gesloten</td>
</tr>
</tbody>
</table>
</td>
<td style="vertical-align: top;background: #777777;">
Dummy data <br />
TODO: Address info
</td>
</tr>
<tr>
<td class="top_td" style="text-align:center;font-size:14px;font-family:Verdana;font-weight:bold;color:#ffffff;">
<strong>INLINE CSS</strong>
</td>
<td class="top_td" style="text-align:center;font-size:14px;font-family:Verdana;font-weight:bold;color:#ffffff;">
<strong>WORKS</strong>
</td>
<td class="top_td" style="text-align:center;font-size:14px;font-family:Verdana;font-weight:bold;color:#ffffff;">
<strong>PERFECTLY FINE</strong>
</td>
</tr>
</table>
</div>
【问题讨论】:
标签: css