[原创]利用CSS的Expression自定义属性来实现表格的OnMouseOver特效
在我们使前后台分开的同时,有时我们想也用CSS来实现只有在JS里才能实现的动作,看似不可能的事情,但经过我的努力,但很好的工作了.
我们知道 CSS 的Exprssion 在IE窗体需要重画时以及有鼠标动作时执行.所以不能直接用它来实现,这样当你的内容多时再快的计算机也受不了(原因是你的鼠标动一下,Expression就执行好几百次).
为了避免这种情况,我们让我们的Expression第一次执行一次操作,以后就简单的返回,这样就可以大大的节省CPU.
费话少说,下面是示例代码(偶是程序员,也不知道说什么了!):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<style>
body
{
}
/*
作者:阿牛(牛昆亮) QQ:273352165 MSN:niukl@hotmail.com
![](/Images/OutliningIndicators/InBlock.gif)
声明:可以免费使用,请您保留此信息(大家都是作程序的,帮个忙了).
如果您有什么改过,记得告诉我!
*/
.dgInit
{
over:expression(((this.readyState=="complete") && (this.className=="dg")) || (
(
__evlon_init_tr=function(objTable){
var i;
for(i=0;i<objTable.rows.length;i++)
{
objTable.rows[i].onmouseover=function(){this.className="dg_tr_mouseover"};
objTable.rows[i].onmouseout=function(){this.className="dg_tr_normal"};
objTable.rows[i].className="dg_tr_normal";
}
}
) ,(__evlon_init_tr(this)), (this.className="dg")));
}
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
.dg
{
}
.dg_tr_mouseover,.dg_tr_normal
{
font-style: italic;
color:blue;
![](/Images/OutliningIndicators/InBlock.gif)
}
![](/Images/OutliningIndicators/InBlock.gif)
.dg_tr_mouseover
{
background-color:#000000;
}
.dg_tr_normal
{
background-color:#ffffff;
}</style>
</head>
<body >
<table class="dgInit"><!--ֻҪ Class -->
<tr >
<td> ni hao </td>
<td> ni hao </td>
<td> ni hao </td>
</tr>
<tr >
<td> ni hao </td>
<td> ni hao </td>
<td> ni hao </td>
</tr>
</table>
</body>
</html>
我们知道 CSS 的Exprssion 在IE窗体需要重画时以及有鼠标动作时执行.所以不能直接用它来实现,这样当你的内容多时再快的计算机也受不了(原因是你的鼠标动一下,Expression就执行好几百次).
为了避免这种情况,我们让我们的Expression第一次执行一次操作,以后就简单的返回,这样就可以大大的节省CPU.
费话少说,下面是示例代码(偶是程序员,也不知道说什么了!):
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
QQ:273352165
evlon#126.com
转载请注明出处。