CSS隐藏数据解决方案



css可能会隐藏以下: <a data-toggle="collapse"></a>没有隐藏第一个<a>?只有CSS?

<a href="edit.html">
   <i class="pull-left fa fa-lg fa-calendar-plus-o" aria-hidden="true"></i>
</a>

  <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
   <li>
      <a href="edit.html">
       <i class="pull-left fa fa-lg fa-calendar-plus-o" aria-hidden="true"></i>
      </a>
       <a data-toggle="collapse" data-target="#collapse" aria-expanded="false" aria-controls="collapse" class="">Collapse</a>
    </li>

您可以将data-toggle属性用作So ...

的选择器
[data-toggle="collapse"] {
    display: none;
}

我必须指出,这不是关注和/或最佳实践的良好分离。

您可以使用CSS选择器:

a:nth-of-type(2){
display:none;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
   <li>
      <a href="edit.html">
       <i class="pull-left fa fa-lg fa-calendar-plus-o" aria-hidden="true"></i>
      </a>
       <a data-toggle="collapse" data-target="#collapse" aria-expanded="false" aria-controls="collapse" class="">Collapse</a>
    </li>

a:last-child{
display:none;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
   <li>
      <a href="edit.html">
       <i class="pull-left fa fa-lg fa-calendar-plus-o" aria-hidden="true"></i>
      </a>
       <a data-toggle="collapse" data-target="#collapse" aria-expanded="false" aria-controls="collapse" class="">Collapse</a>
    </li>

您可以使用:最后一个孩子参考最后标签

[data-toggle="collapse"] {
    display: none;
}

相关内容

  • 没有找到相关文章