html
<button class="customer-btn">鹿晗</button>
<button class="customer-btn">宋茜</button>
<button class="customer-btn">郑秀晶</button>
<button class="customer-btn">吴亦凡</button>
<button class="customer-btn">关晓彤</button>
css
.customer-btn{background-color: #5c88ff;;}
.customer-btn:hover,
.customer-btn:focus,
.customer-btn:active,
.customer-btn:active,
.customer-btn:active{
background-color: #5c88ff;
color: #ffff;
}
.customer-case button{
width: 140px;
height: 48px;
border: 2px solid #5c88ff;
background-color: #ffff;
border-radius: 30px;
color: #5c88ff;
font-size: 18px;
}
.btns-success{
background-color:#5c88ff;
color: #ffff;
}
.sactive{
background-color:#5c88ff!important;
color: #ffff!important;
}
button{
outline:none;
}
jquery
/* button按钮点击变色 */
$(function() {
$('.content>button:eq(0)').addClass('sactive');
$('button').click(function(){
$('.content>button:eq(0)').removeClass('sactive');
$(this).addClass("btns-success").siblings("button").removeClass("btns-success").addClass("customer-btn");
});
});