【发布时间】:2022-01-02 23:34:02
【问题描述】:
我有这个侧边栏
我希望通过将项目的颜色更改为白色并将图标更改为黑色来激活项目
这是我迄今为止尝试过的
Css 代码
.sidebar li a {
display: flex;
height: 100%;
width: 100%;
border-radius: 12px;
align-items: center;
text-decoration: none;
transition: all 0.4s ease;
background: #76b852;
}
.sidebar li a:hover{
background: #FFF;
}
.sidebar li a.active{
background-color: #FFF;
color: white;
}
HTML 代码
<li <?php if($currentFile=="dashboard.php"){?>class="active"<?php }?>>
<a href="dashboard.php">
<i class="material-icons">
<span class="material-icons">dashboard</span>
</i>
<span class="links_name">Dashboard</span>
</a>
<span class="tooltip">Dashboard</span>
</li>
问题似乎就在这里
.sidebar li a.active{
background-color: #FFF;
color: white;}
当我只添加“l”而不添加“a”时,激活的项目显示如下截图
我没有网络开发经验,希望有人帮助我
【问题讨论】: