在react bootstrap中使用LinkContainer
时活动";CCD_ 2得到blue
,因为它是background-color
。例如:
<NavDropdown>
<LinkContainer to="/profile">
<NavDropdown.Item>profile</NavDropdown.Item>
</LinkContainer>
<LinkContainer to="/">
<NavDropdown.Item>
logout
</NavDropdown.Item>
</LinkContainer>
</NavDropdown>
如何删除它并将其替换为我自己的颜色?
我试过这样做:
a .active.dropdown-item {
background-color: white
}
解决方案(假设我们想添加绿色作为背景(:
-
单击链接即显示活动链接:-
a.下拉项:活动{背景颜色:绿色;}
-
使颜色保持在活动NavDropdown上。项目:
a.active.drop-downitem{背景颜色:绿色;}或
你可以在
LinkContainer
中添加activeStyle
道具<链接容器to="/配置文件";activeStyle={{背景颜色:";绿色";,}}/>
我没有React Bootstrap的经验,但我想它得到的是伪类:active
。
所以你必须做一些类似的事情:
a:active {
background-color: white
}
https://www.w3schools.com/cssref/sel_active.asp