【发布时间】:2021-12-08 05:29:26
【问题描述】:
我想知道如何添加在您当前所在页面的导航栏上添加突出显示框的功能。你知道这样人们就知道他们在哪个页面上。
非常喜欢这个网站,活动页面上有白框:https://woodycraft.net/home/
这是我的导航栏的 CSS:
/*TOP NAV BAR SECTION*/
*{margin: 0px;
padding: 0px;}
#nav_bar {background-color: #a22b2f;
box-shadow: 0px 2px 10px;
height: 45px;
text-align: center;}
#nav_bar > ul > li {display: inline-block;}
#nav_bar ul > li > a {color: white;
display: block;
text-decoration: none;
font-weight: bold;
padding-left: 10px;
padding-right: 10px;
line-height: 45px;}
#nav_bar ul li ul {display: none;
list-style: none;
position: absolute;
background: #e2e2e2;
box-shadow: 0px 2px 10px;
text-align: left;}
#nav_bar ul li a:hover {background: #8e262a;}
#nav_bar a:active {background: white;}
#nav_bar ul li:hover ul {display: block;}
#nav_bar ul li ul li a {color: #252525;
display: block;}
#nav_bar ul li ul li a:hover {background: #4485f5;
color: #fff;}
这是我的一个页面的 HTML:
<!--TOP NAV BAR SECTION-->
<div id="nav_bar">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="status.html">Status</a></li>
<li><a href="info.html">Info</a></li>
<li><a href="#">Gamemodes</a>
<ul>
<li><a href="survival.html">Survival</a></li>
<li><a href="pure-pvp.html">Pure-PVP</a></li>
<li><a href="gamesworld.html">Gamesworld</a></li>
</ul>
</li>
<li><a href="rules.html">Rules</a></li>
<li><a href="vote.html">Vote</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
【问题讨论】:
-
在当前页面上为您的项目添加一个类(例如“已选择”)并设置特定项目的样式:)