html5支持多中浏览器写法,html5及css3对table表格高亮当前行列的多浏览器兼容写法...

html5能轻松实现高亮当前行、指定奇偶行颜色(斑马色),但纯用css3实现列方向就比较困难,而且在老式IE浏览器也不能兼容。本例就是实现行列高亮,并且兼容IE。本例需要用到jquery。

body {

font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;

color: #4f6b72;

background: #E6EAE9;

}

#mytable {

width: 700px;

padding: 0;

margin: 0;

text-align : center ;

}

.table-heading{

font-family : Georgia, serif;

font-size : 18px ;

color : blue ;

background-color : yellow ;

}

.odd{

background-color : #ffc;  /*奇数行浅黄*/

}

.even{

background-color : #cef ;/*偶数行浅蓝*/

}

td {

border-right: 1px solid #C1DAD7;

border-bottom: 1px solid #C1DAD7;

font-size:11px;

padding: 6px 6px 6px 12px;

color: #4f6b72;

}

.tdhlight{

color : red ;

font-weight : 900 ;

}

.rc-hlight{

background-color : #cc99ff ;}

.foucs-hlight{

background-color : #ff6600 ;}

.hidden{

display : none ;}

$(document).ready(

function(){

//            $('tr:odd').addClass('odd');

//            $('tr:even').addClass('even');

$('th').parent().addClass('table-heading');

//            $('tr:not([th]):even').addClass('even');

//            $('tr:not([th]):odd').addClass('odd');

$('tr:not(:has(th)):odd').addClass('odd');

$('tr:not(:has(th)):even').addClass('even');

$('td:contains("showtime")').siblings().addClass('tdhlight');

}

);

$(document).ready(

function(){

$('#mytable td').hover(

function(){

var nu = $(this).parent().children('td').index($(this)[0]);

$("#mytable tr:not(:has(th))").each(

function(i){

$(this).children("td").eq(nu).addClass('rc-hlight');

}

);

$(this).parent().addClass('rc-hlight');

$(this).addClass('foucs-hlight');

},

function(){

var nu = $(this).parent().children('td').index($(this)[0]);

$("#mytable tr:not(:has(th))").each(

function(i){$(this).children("td").eq(nu).removeClass('rc-hlight');}

);

$(this).parent().removeClass('rc-hlight');

$(this).removeClass('foucs-hlight');

}

);

}

);

nameageidsex
shiyang18001female
showtime23002male
wuyan19003male
huanlili89004female
nanci48005female
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值