欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

用事件与CSS改变按钮不同状态下的颜色_html/css_WEB-ITnose

程序员文章站 2022-05-21 20:07:17
...
目标效果:

    表单的群发按钮,在鼠标悬停时为深蓝色,鼠标离开时为淡蓝色。

HTML代码:

    

CSS代码:

.btn{
color:#ffffff;
background:#44b549;
padding-top:3px;
border-top: 1px solid #44b549;
border-right: 1px solid #44b549;
border-bottom: 1px solid #44b549;
border-left: 1px solid #44b549;
width:100px;
height:30pt;
font-size:15pt;
border-radius:3em;
background-image: linear-gradient(to bottom, #44b549 0px, #44b549 100%);
-moz-border-radius: 5px;
} 注意一定不能少了这一段,此段定义打开页面时按钮的初始样式。若没有这段,页面打开时按钮不显示样式,直至有鼠标悬停。

.input_move{
color:#ffffff;
background:#006600;
padding-top:3px;
border-top: 1px solid #006600;
border-right: 1px solid #006600;
border-bottom: 1px solid #006600;
border-left: 1px solid #006600;
width:100px;
height:30pt;
font-size:15pt;
border-radius:3em;
background-image: linear-gradient(to bottom, #006600 0px, #006600 100%);
-moz-border-radius: 5px;
}
.input_out{
color:#ffffff;
background:#44b549;
padding-top:3px;
border-top: 1px solid #44b549;
border-right: 1px solid #44b549;
border-bottom: 1px solid #44b549;
border-left: 1px solid #44b549;
width:100px;
height:30pt;
font-size:15pt;
border-radius:3em;
background-image: linear-gradient(to bottom, #44b549 0px, #44b549 100%);
-moz-border-radius: 5px;
}