积极答复者
请问如何将onmouseover放到样式表文件里

问题
-
我想把onmouseover放到样式表文件中。不是放在ASPX页面中。
<style type="text/css">
.showCSS{
event:expression(
onmouseover = function()
{
this.style.backgroundColor='#f0f0f0'
},
onmouseout = function()
{
this.style.backgroundColor='#ffffff'
}
)
}
</style>
象这种方式写在aspx文件中的不要,要写在.css文件中的那种。我把这种方式改写到.css文件中不起作用。- 已移动 孟宪会Moderator 2010年3月4日 0:40 (发件人:ASP.NET 与 AJAX)
答案
全部回复
-
鼠标经过表格变色样式:
<style>
table { background-color:#000000; cursor:hand; width:100%; }
td {
/*设置onmouseover事件*/
onmouseover: expression(onmouseover=function (){this.style.borderColor ='blue';this.style.color='red';this.style.backgroundColor ='yellow'});
/*设置onmouseout事件*/
onmouseout: expression(onmouseout=function (){this.style.borderColor='';this.style.color='';this.style.backgroundColor =''});
background-color:#ffffff;
}
</style>
控制表格隔行变色:
简单应用:
<style type="text/css">
<!--
tr {background-color:expression((this.sectionRowIndex%2==0)?"#E1F1F1":"#F0F0F0")}
-->
高级应用:每个单元格变色
<style type="text/css">
<!--
tr {background-color:expression((this.sectionRowIndex%2==0)?"red":"blue")}
td {background-color:expression((this.cellIndex%2==0)?"":((this.parentElement.sectionRowIndex%2==0)?"green":"yellow"))}
-->
</style>
添加CSS文件引用:
<link id="cssStyle" rel="stylesheet" type="text/css" href="../style.css" />
可能对你有点帮助
咯咯 -
我想把onmouseover放到样式表文件中。不是放在ASPX页面中。
你好cycc,应该可以这样写:
<style type="text/css">
.showCSS{
event:expression(
onmouseover = function()
{
this.style.backgroundColor='#f0f0f0'
},
onmouseout = function()
{
this.style.backgroundColor='#ffffff'
}
)
}
</style>
象这种方式写在aspx文件中的不要,要写在.css文件中的那种。我把这种方式改写到.css文件中不起作用。
.abc{
abc:expression(this.onmouseover=function(){/*do some thing*/});
}
我们要把爱心传递给更多需要帮助的人。
博客:http://terryfeng.cnblogs.com
微博:http://t.sina.com.cn/terryfeng
个人:http://www.terryfeng.com