我正在努力在现有站点上移动一些导航项目,但是不熟悉php(尽管我认为这只是一个CSS问题)。问题在于,单击(活动)时,某些导航项正确加了下划线,而其他导航项则没有。
我已经尝试过使用网站外部的代码,但是因为它也是PHP,所以我无法在浏览器中正确显示它
#main_nav .active{
text-decoration: underline!important;
}
<nav id="main_nav" class="nav-mobile col-md-8 col-md-pull-4 col-md-float-break">
<ul>
<li id="home_link"><a href="/<?php echo $data['lang']['language']; ?>" <?php if ($data['page_info']['disc'] == 'home') echo 'class="active"'; ?> ><?php echo $data['lang']['home_link']; ?></a></li>
<li id="started_link"><a href="/<?php echo $data['lang']['language']; ?>/get-started" <?php if ($data['page_info']['disc'] == 'get_started') echo 'class="active"'; ?> ><?php echo $data['lang']['started_link']; ?></a></li>
<li id="new_vehicle_link"><a href="/<?php echo $data['lang']['language']; ?>/lease-or-purchase" <?php if ($data['page_info']['disc'] == 'lease-or-purchase') echo 'class="active"'; ?> ><?php echo $data['lang']['new_vehicle_link']; ?></a></li>
<li id="keep_vehicle_link"><a href="/<?php echo $data['lang']['language']; ?>/purchase-your-vehicle" <?php if ($data['page_info']['disc'] == 'purchase-your-vehicle') echo 'class="active"'; ?> ><?php echo $data['lang']['keep_vehicle_link']; ?></a></li>
<li id="vehicle_link"><a href="/<?php echo $data['lang']['language']; ?>/turn-in-your-vehicle" <?php if ($data['page_info']['disc'] == 'turn_in_your_vehicle') echo 'class="active"'; ?> ><?php echo $data['lang']['vehicle_link']; ?></a></li>
</ul>
</nav>
答案 0 :(得分:0)
这是因为您从破折号切换为下划线。
入门-> get_started
上车-> turn_in_your_vehicle
这些将永远不会匹配,因此它们将永远不会active