我正在尝试使这些按钮符合我的CSS,但它们不是样式。
我做了新的按钮,它们也没有按照我的CSS样式设置。但是我注意到该文本是大写的,这是css的一部分,这使我认为其中的一部分是错误的。
<section id="gallery" class="content-section text-center">
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto">
<button class="btn active" onclick="filterSelection('all')">Show all</button>
<button type="button" onclick="filterSelection('sealion')">Sea Lions</button>
</div>
.btn {
font-family: 'Cabin', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-weight: 400;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
text-transform: uppercase;
border-radius: 0;
}
.btn-default {
color: #42DCA3;
border: 1px solid #42DCA3;
background-color: transparent;
}
.btn-default:focus, .btn-default:hover {
color: black;
border: 1px solid #42DCA3;
outline: none;
background-color: #42DCA3;
}
预期结果是按钮是带有白色文本和绿色边框的黑色矩形。悬停按钮后,该按钮将变为绿色。
答案 0 :(得分:0)
将类btn-default
添加到button
tag
<section id="gallery" class="content-section text-center">
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto">
<button class="btn btn-default active" onclick="filterSelection('all')">Show all</button>
<button type="button" onclick="filterSelection('sealion')">Sea Lions</button>
</div>
答案 1 :(得分:0)
您需要先在btn-default
中添加类button
,然后使用所有按钮类(例如css
)给.btn.active.btn-default
来覆盖bootstrap
{{1} }
css
答案 2 :(得分:0)
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style type="text/css">
.btn {
font-family: 'Cabin', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-weight: 400;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
text-transform: uppercase;
border-radius: 0;
}
.btn.active.btn-default {
color: #42DCA3;
border: 1px solid #42DCA3;
background-color: transparent;
}
.btn.active.btn-default:focus, .btn.active.btn-default:hover {
color: black;
border: 1px solid #42DCA3;
outline: none;
background-color: #42DCA3;
}
.btn.active.btn-primary {
color: #42DCA3;
border: 1px solid #42DCA3;
background-color: transparent;
}
.btn.active.btn-primary:focus, .btn.active.btn-primary:hover {
color: black;
border: 1px solid #42DCA3;
outline: none;
background-color: #42DCA3;
}
</style>
<section id="gallery" class="content-section text-center">
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto">
<button class="btn active btn-default" onclick="filterSelection('all')">Show all</button>
<button class="btn btn-primary active" onclick="filterSelection('sealion')">Sea Lions</button>
</div>
</div>
</div>
</section>
尝试此代码,现在可以使用