[英]Overlap border-left CSS
I have a menu with some css on it. 我有一个菜单,上面有一些CSS。 I activate it when the page is active
我在页面处于活动状态时将其激活
<li <?php echo (strpos(current_url(), 'history') !== false) ? "class='active'" : ""; ?>>
<a href="<?= base_url() ?>dashboard/history">History</a>
</li>
I also have css for menu it self when is hover and focus 悬停和聚焦时,我也有自己的菜单CSS
.side-nav li a:hover,
.side-nav li a:focus {
outline: none;
background-color: #f8f8f8 !important;
font-weight: bold;
border-left: 6px solid #337AB7;
-webkit-box-shadow: -4px 4px 6px -4px #a5a5a5;
box-shadow: -4px 4px 6px -4px #a5a5a5;
}
And class active is 课堂活动是
.side-nav li.active{
background-color: #f8f8f8 !important;
font-weight: bold;
border-left: 6px solid #337AB7;
-webkit-box-shadow: -4px 4px 6px -4px #a5a5a5;
box-shadow: -4px 4px 6px -4px #a5a5a5;
}
My problem is when active class is active and i hover over the menu bar i have 2 borders on that element. 我的问题是活动类处于活动状态,并且将鼠标悬停在菜单栏上时,该元素上有2个边框。 How can i remove the second border when element is active?
元素处于活动状态时如何删除第二个边框?
Your problem is, that you are accessing two different elements with your css. 您的问题是,您正在使用CSS访问两个不同的元素。 With the first definition you are accessing the pseudo-selectors
:focus
and :hover
on any a
element within a li
element in your .side-nav
. 随着第一个定义,你正在访问的伪选择
:focus
和:hover
的任何上a
一个元素内li
在你的元素.side-nav
。 With the second definition you are only accessing the li
element, and not the contained a
element. 使用第二个定义,您仅访问
li
元素,而不访问所包含a
元素。 Defining your .active
class as follows should fix your problem: 如下定义
.active
类可以解决您的问题:
.side-nav li.active a {
background-color: #f8f8f8 !important;
font-weight: bold;
border-left: 6px solid #337AB7;
-webkit-box-shadow: -4px 4px 6px -4px #a5a5a5;
box-shadow: -4px 4px 6px -4px #a5a5a5;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.