利用bootstrap实现圆形按钮 选中变色

下载bootstrap包 其他的都在代码中

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
         <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
         <link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css">
         <style type="text/css">
            body{
                text-align: center;
            }

            .btn-my { 
                 /*background: #cb60b3; Old browsers */ 
                /*background: -moz-linear-gradient(top, #cb60b3 0%, #ad1283 50%, #de47ac 100%); FF3.6+ */ 
                /* background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #cb60b3),color-stop(50%, #ad1283), color-stop(100%, #de47ac) ); Chrome,Safari4+ */ 
                /* background : -webkit-linear-gradient( top, #cb60b3 0%,#ad1283 50%, #de47ac 100%);  Chrome10+,Safari5.1+ */ 
                /* background: -o-linear-gradient(top, #cb60b3 0%, #ad1283 50%, #de47ac 100%);Opera 11.10+ */ 
                /* background: -ms-linear-gradient(top, #cb60b3 0%, #ad1283 50%, #de47ac 100%); IE10+ */ 
                /* background: linear-gradient(to bottom, #cb60b3 0%, #ad1283 50%, #de47ac 100%); W3C */ 
                filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cb60b3',endColorstr='#de47ac', GradientType=0 ); /* IE6-9 */ }
            .btn-my{ width: 55px; height: 55px; -moz-border-radius: 50%; -webkit-border-radius: 50%; border-radius: 50%; }
            .active{
                background: forestgreen;
                color:#F8F8F8;
            }

         </style>

    </head>
    <body>
        <!-- 自定义按钮样式 --> 
        <button type="button" class="btn btn-my" name="one" id="5">5<br/>分钟</button>
        <button type="button" class="btn btn-my" name="one" id="10" >10<br/>分钟</button>

        <script src="js/bootstrap.min.js"></script>
        <script src="js/jquery-1.8.3.min.js"></script>
        <script type="text/javascript">
            $(function(){
                $("[name=one]").click(function(){
                    alert(this.id);
                    //this可以获取当前点击按钮的id
                    if(this.className.indexOf('active')==-1){
                        this.className="active btn-my btn";
                        this.style="color: #FFFFFF;"
                    }else{
                        this.className=" btn-my btn";
                        this.style="color: #000000;"
                    }
                })
                $("[name=one]").blur(function(){
                    this.className="btn-my btn";
                    this.style="color: #000000;";
                })

            })

        </script>
    </body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值