在第一个li后我的Bootstrap 4中的面包屑我需要能够删除正斜杠
更改
位置:/目录
到
位置:目录
问题:如何删除bootstrap breadcrumbs上的第一个正斜杠
我试过
.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>
答案 0 :(得分:3)
我相信你正在寻找的是这个。
由于Bootstrap在从第二个元素开始的元素之前添加/
,我们必须使用nth-child()
CSS选择器来选择第二个元素。
.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;
答案 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;
}