星空网 > 软件开发 > 网页设计

用事件与CSS改变按钮不同状态下的颜色

目标效果:

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

HTML代码:

    <button id="submitBtn"  onmouseover="this.className='input_move'" onmouseout="this.className='input_out'" type="submit" tabindex="6">群    发</button>
            <button id="previewBtn"  onmouseover="this.className='input_move'" onmouseout="this.className='input_out'" type="submit" tabindex="6">预    览</button>

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;
}

    

 




原标题:用事件与CSS改变按钮不同状态下的颜色

关键词:CSS

CSS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

意大利专线:https://www.goluckyvip.com/tag/47775.html
意大利专线货运:https://www.goluckyvip.com/tag/47776.html
意大利专线物流:https://www.goluckyvip.com/tag/47777.html
翼飞海外仓:https://www.goluckyvip.com/tag/47778.html
越南产品:https://www.goluckyvip.com/tag/4778.html
翼果科技:https://www.goluckyvip.com/tag/47780.html
湘西游轮六 湘江游轮夜游:https://www.vstour.cn/a/411226.html
携程旅游网折扣优惠最新攻略(携程旅游网更佳折扣优惠):https://www.vstour.cn/a/411227.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流