gpt4 book ai didi

twitter-bootstrap - 关于设置 Bootstrap 事件按钮背景颜色的问题

转载 作者:行者123 更新时间:2023-11-28 06:26:05 27 4
gpt4 key购买 nike

你能看看this demo吗?让我知道为什么我没有在 bootstrap 3 中为按钮的事件状态设置背景颜色?我期望的是在单击后将背景颜色设置为红色,直到鼠标悬停在按钮上,但一旦鼠标离开,它就会再次变为透明!

谢谢

.btn-sample
{
text-shadow: none;
color: white;
background:transparent;
border:2px solid red;
color:red;
}
.btn-sample:hover
{
text-shadow: none;
color: white;
background:red;
}
.btn-sample:active {
box-shadow: none;
background-color: red;
}
.btn-sample.active {
background-color: red;
}
.btn-sample:active:focus {
color: #ffffff;
background-color: red;
}
.btn-sample.active:focus{
background-color: red;
}
.btn-sample:active:focus{
background-color: red;
}

最佳答案

当您单击按钮时,Bootstrap 不会自动附加 active 类。你需要一点 jQuery(或者你可以使用 javascript)来为你做这件事。

试试这个:

$('.btn-sample').click(function() {
$(this).toggleClass('active');
});

Updated your link here

关于twitter-bootstrap - 关于设置 Bootstrap 事件按钮背景颜色的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35278675/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com