|M| 我们知道样式A有a:hover {} 也就是鼠标移到时的CSS 现在我想给button 也加这个功能要如何实现
也就是我的button鼠标移动的时候改变button样式
谢谢
------解决方案--------------------onmouseover= "this.style= '你的样式 ' "
------解决方案--------------------onmouseover
------解决方案--------------------添加 <link href= "css/css.css " type= "text/css " rel= "Stylesheet " />
对css的引用
在css中写上
.btn1 {
border-right: #7b9ebd 1px solid; padding-right: 2px; border-top: #7b9ebd 1px solid; padding-left: 2px; font-size: 12px; filter: progid:dximagetransform.microsoft.gradient(gradienttype=0, startcolorstr=#ffffff, endcolorstr=#cecfde); border-left: #7b9ebd 1px solid; cursor: hand; color: black; padding-top: 2px; border-bottom: #7b9ebd 1px solid; width:70;
}
.btn2 {
border-right: #7ebf4f 1px solid; padding-right: 2px; border-top: #7ebf4f 1px solid; padding-left: 2px; font-size: 12px; filter: progid:dximagetransform.microsoft.gradient(gradienttype=0, startcolorstr=#ffffff, endcolorstr=#cae4b6); border-left: #7ebf4f 1px solid; cursor: hand; color: black; padding-top: 2px; border-bottom: #7ebf4f 1px solid; width:70;
}
<input class= "btn1 " onmouseover= "this.className= 'btn2 ' " onmouseout= "this.className= 'btn1 ' " name= "submit " type= "submit " id= "btnSub " value= " 确 定 " runat= "server " onserverclick= "btnSub_ServerClick " />
------解决方案--------------------onmouseover,onmouseout指向不同的css中的项
------解决方案--------------------一楼说的准确。
------解决方案--------------------可以直接写在页面代码中onmouseover= "this.bgcolor= '#000000 ' "
或者用htc,在css中的button的样式中用behavior
.button
{
behavior:url(a.htc);
}
a.htc:
<PUBLIC:COMPONENT>
<PUBLIC:ATTACH EVENT= "onmouseover " ONEVENT= "ChangeColor() " />
<SCRIPT LANGUAGE=\ "JScript\ ">
function ChangeColor()
{
this.bgcolor = '#000000 ';
}
</SCRIPT>
</PUBLIC:COMPONENT>
------解决方案--------------------我上面改的bgcolor,楼主改为改style就ok
------解决方案--------------------其实只要能实现效果,在不影响性能时,管他什么方法呢
------解决方案-------------------- <SCRIPT LANGUAGE= "JScript ">
function ChangeColor()
{
this.style.backgroundColor = '#000000 ';
}
</SCRIPT>