Bootstrap 4删除面包屑中的第一个正斜杠

时间:2017-08-24 12:16:12

标签: css twitter-bootstrap bootstrap-4

在第一个li后我的Bootstrap 4中的面包屑我需要能够删除正斜杠

更改

位置:/目录

位置:目录

  

问题:如何删除bootstrap breadcrumbs上的第一个正斜杠

enter image description here

我试过

.breadcrumb-item:first-of-type::before {
    display: inline-block;
    padding-right: 0.5rem;
    padding-left: 0.5rem;
    color: #868e96;
    content: "";
}

HTML

<div class="modal-header justify-content-center">
<ol class="breadcrumb">
<li class="breadcrumb-item">Location: </li>
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<li class="breadcrumb-item"><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
<?php } ?>
</ol>
</div> 

4 个答案:

答案 0 :(得分:3)

我相信你正在寻找的是这个。

由于Bootstrap在从第二个元素开始的元素之前添加/,我们必须使用nth-child() CSS选择器来选择第二个元素。

&#13;
&#13;
.breadcrumb .breadcrumb-item:nth-child(2)::before {
  content: "";
}
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">

<div class="modal-header justify-content-center">
  <ol class="breadcrumb">
    <li class="breadcrumb-item">Location: </li>
    <li class="breadcrumb-item"><a href="#">Content</a></li>
  </ol>
</div> 

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

使用选择器.breadcrumb-item:first-of-type+.breadcrumb-item::before根据需要设置content伪元素的:before

.my-breadcrumb .breadcrumb-item:first-of-type+.breadcrumb-item::before {
    content: "";
}

.dot-breadcrumb .breadcrumb-item:first-of-type+.breadcrumb-item::before {
    content: "...";
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>

<ol class="breadcrumb">
  <li class="breadcrumb-item"><a href="#">Home</a></li>
  <li class="breadcrumb-item"><a href="#">Library</a></li>
  <li class="breadcrumb-item active">Data</li>
</ol>

<ol class="breadcrumb my-breadcrumb">
  <li class="breadcrumb-item"><a href="#">Home</a></li>
  <li class="breadcrumb-item"><a href="#">Library</a></li>
  <li class="breadcrumb-item active">Data</li>
</ol>

<ol class="breadcrumb dot-breadcrumb">
  <li class="breadcrumb-item"><a href="#">Home</a></li>
  <li class="breadcrumb-item"><a href="#">Library</a></li>
  <li class="breadcrumb-item active">Data</li>
</ol>

答案 2 :(得分:1)

之前的选择器从第二个孩子开始。所以你可以这样:

.breadcrumb-item:nth-child(2):before  {
  content: '';
  padding-right: 0;
}

我还覆盖了Bootstrap的padding-right来解释列表项之间的新间距。

答案 3 :(得分:0)

使用此选择器,

.breadcrumb-item+.breadcrumb-item::before{
    content: ">";
    color: white;
 }