当前位置: 移动技术网 > IT编程>网页制作>CSS > css3 条纹化和透明化表格Firefox下测试成功

css3 条纹化和透明化表格Firefox下测试成功

2019年07月25日  | 移动技术网IT编程  | 我要评论
使用class来条纹化表格,需要在html中将表格中每一行都按<tr><td></td></tr>写出,非常麻烦。

css3中的伪类渲染更能很好地定位页面元素。

然而有时即使你按照css3格式来写,在浏览器中却显示不出相应的效果,这时就需要考虑浏览器的兼容问题。

目前,全盘支持 css3 属性的浏览器有 chrome 和 safari,而且不管是 mac 平台还是 windows 平台全支持。

博主先用ie没有成功,后用firefox成功。

现附上条纹化表格的代码:

html:

复制代码
代码如下:

<table>
<thead>
<tr>
<th>synonym</th>
<th>cosine</th>
</tr>
</thead>
<tbody>
{% for w in words %}
<tr>
<td>{{ w.0}}</td><td>{{ w.1}}</td>
</tr>
{% endfor %}
</tbody>
</table>

css:rbga(,,,)最后一个参数是调整透明度

复制代码
代码如下:

table{
font-family:"trebuchet ms", arial, helvetica, sans-serif;
width:70%;
border-collapse:collapse;
position:relative;
left:50px;
}
thead th{
font-size:1.2em;
text-align:left;
padding-top:5px;
padding-bottom:4px;
background-color:#663366;
color:#ffffff;
border:1px solid #990099;
padding:3px 7px 2px 7px;
}
tbody tr,td{
font-size:1em;
border:1px solid #990099;
padding:3px 7px 2px 7px;
}
tbody tr:nth-of-type(even){
background-color:rgba(138,43,226,0.2);
}
tbody tr:nth-of-type(odd){
background-color:rgba(169,169,169,0.2);
}

最后的效果图:

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网