css - 使用其他框架(如 Materialise)时,如何在 Bootstrap Navbar Toggler Icon 处于活动状态时更改其背景颜色?
问题描述
我正在做一个需要 Bootstrap 和 Materialize 框架的项目。我有这个导航栏切换,当不处于活动状态时这是正常的。
但是当它进入活动状态并使用 Materialize CSS 的默认颜色填充背景时。
我正在尝试将背景颜色设置为透明,但事实并非如此。这是我尝试过的 CSS。
.navbar-toggler-icon{
background-color: transparent !important;
}
.navbar-toggler-icon :active{
background-color: transparent !important;
}
这是 codepen链接。
解决方案
I've added an id
in the div
that has all the content of thenavbar
.
<body>
<div class="navbar navbar-dark navbar-expand-lg sticky-top w-100" >
<div id="color" class="container p-2">
<a class="navbar-brand font-weight-bold text-white mx-5 d-none d-sm-block" href="#">ReEvent</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</div>
</div>
</body>
When I change the color in an id
if the id
is on the div
everything that is inside the div
will be change together. So I put it just for the button
receive the changes.
But, I don't know why, the button keeps with the "bug" if you put the :focus
just on it, so i've put the :focus
on everything and after this I've removed the :focus
of the a
using one specific bg for him.
body{
background-color: #222;
}
.navbar-toggler-icon{
background-color: transparent !important;
}
#color button :hover, #color :focus, #color button :active{
background-color: transparent !important;
}
#color a :focus {
background-color: white !important;
}
推荐阅读
- powershell - 检查并在 Windows Server 2008/2012/2016 上安装 Web 浏览器
- python - 如何在python中替换pandas中的整数值?
- typescript - 如何使用 cash.js TypeScript 声明?
- c++ - 如何避免显式构造 C++ 初始化列表中继承的所有内容?
- c# - “如何修复 PHP 中的‘标头已发送’错误”
- python - 无法枚举浮点数,但是还有另一种方法可以解决这个问题吗?
- react-native - 如何从位于同一文件但不同类的不同类中调用 setState?
- haskell - How to quickCheck all possible cases for a type that is both Enum and Bounded?
- ios - How to fix issue regarding pkpass not working after dragging to ios simulator?
- rust - How to solve "returns a value referencing data owned by the current function" error in Rust?