您对此有何想法?
<style>
.table {
width: 100%;
display:table;
border-collapse: collapse;
}
.tr {
height: 60px;
display:table-row;
border: 1px solid Black;
}
.td, .th{
height: 60px;
border: 1px solid Black;
display:table-cell;
background: -webkit-linear-gradient(top, #ccc 0%, #888 100%);
}
</style>
<div class="table">
<div class="tr">
<div class="th"></div>
</div>
<div class="tr">
<div class="td"></div>
</div>
<div class="tr">
<div class="td"></div>
</div>
</div>
最好使用DIV而不是表格。你可以用小的改变做同样的事情。 如果您使用PDF或通过模板等电子邮件发送,那么最好将CSS内联添加到HTML。
UPDATE:
你可以这样做:
<style>
table {
width: 100%;
border-collapse: collapse;
}
th {
height: 60px;
}
td{height: 100px;}
td, th {
background: -webkit-linear-gradient(top, #ccc 0%, #888 100%);
border: 1px solid Black;
}
</style>
<table>
<tr>
<th></th>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
</table>
或jQuery来使用嵌套的div替换表:
<style>
.table {
width: 100%;
display:table;
border-collapse: collapse;
}
.table .tr{
display:table-row;
}
.table .th{
height: 60px;
font-weight:bold;
}
.table .td{height: 100px;}
.table .th,
.table .td {
border: 1px solid Black;
display:table-cell;
background: -webkit-linear-gradient(top, #ccc 0%, #888 100%);
}
</style>
<table>
<tr>
<th>a</th>
</tr>
<tr>
<td>b</td>
</tr>
<tr>
<td>c</td>
</tr>
</table>
<script>
$(document).ready(function(){
$("table").each(function(a,table){
var i=a;
$(table).after('<div class="table" id="table-'+i+'"></div>');
var currentTH = $(this).parent().find('th');
$(currentTH).each(function(){
var content=$(this).html();
$('#table-'+i).append(' <div class="tr"><div class="th">'+content+'</div></div>');
});
var currentTD = $(this).parent().find('td');
$(currentTD).each(function(){
var content=$(this).html();
$('#table-'+i).append(' <div class="tr"><div class="td">'+content+'</div></div>');
});
$(this).remove();
});
});
</script>
我不认为这将工作不幸。但是,您仍然可以通过使用图像作为背景来实现几乎仅限CSS的解决方案。这对你有用吗? – Nenotlep 2014-12-23 09:01:56
带有图像解决方案的CSS对我来说已经足够好了,但是也可以用这种方法观察到类似的突变渲染。 – stovroz 2014-12-23 16:32:13
以下两点对我来说都是一样的:'background:-webkit-gradient(线性,左上,右下,色阻(0%,rgba(25,25,175,1)),color-stop( (100%,rgba(93,168,226,1)));' 和'background:-webkit-gradient(linear,left top (rgba(25,25,175,1))到(rgba(93,168,226,1)));' – rainabba 2016-02-04 00:18:47