【发布时间】:2013-03-14 14:42:25
【问题描述】:
好的,我的网站顶部菜单中有一个链接列表,每个链接都位于类 div 中。我想将活动链接(当前页面)的边框设置为无;但是我的代码好像有些问题!
顶部菜单链接
<div class="emp_details_link"><a href="<?php echo base_url().'index.php/hr/employee_details/general';?>" >General</a></div>
<div class="emp_details_link"><a href="<?php echo base_url().'index.php/hr/employee_details/contact';?>" >Contact</a></div>
<div class="emp_details_link"><a href="<?php echo base_url().'index.php/hr/employee_details/Relations';?>" >Relations</a></div>
<div class="emp_details_link"><a href="<?php echo base_url().'index.php/hr/employee_details/Work';?>" >Work</a></div>
我的 CSS:
.emp_details_link{
border:1px solid #000000;
width:100px;
height:20px;
float:left;
}
.emp_details_link a{
text-decoration:none;
}
.emp_details_link > a:active{ // poiting to the parent div
border:1px solid red;
border-bottom:none;
}
【问题讨论】:
-
没有一个链接有
active类 -
解决方案是将
active类添加到div.emp_details_link而不是锚元素 -
我还建议您研究 jQuery,因为我发现它更易于使用,但是,您在查看时会遇到未启用 javascript 的人。
-
但我认为 active 是链接的状态,而不是类名或类似的东西!
-
Arun active 不是类它是一个状态:active 处于活动位置或打开的链接位置