Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
504 views
in Technique[技术] by (71.8m points)

sharepoint - How do I use only css to keep a drop down menu open when an item in the menu is selected?

I'm using this css code for my SharePoint site and it currently shows the sub-menu when the main menu item is hovered over. However, when I select an item from the main menu, the sub-menu is hidden again. I want the submenu to remain open if I click on an item and go to the corresponding page so I know which page I am currently on. How do I keep the sub-menu open to show which page I am currently on?

#sideNavBox .ms-core-listMenu-verticalBox ul ul {
 display: none;
}

#sideNavBox .ms-core-listMenu-verticalBox ul li:hover ul {
 display: block;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the :focus pseudo-class, Like:

#sideNavBox .ms-core-listMenu-verticalBox ul li:focus ul {
 display: block;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...