gpt4 book ai didi

css - 如何显示与其他元素颜色不同的面包屑元素

转载 作者:行者123 更新时间:2023-11-28 08:54:45 27 4
gpt4 key购买 nike

我有这个 css 和 html 的面包屑,但我不想要悬停状态。相反,我希望能够在 <li> 中显示一项与其他颜色不同。我尝试使用不同背景的不同类(class),但我失败了。

有人知道怎么做吗?

谢谢!!

body{
font-family:Arial, Helvetica, sans-serif;

}
#crumbs ul li a {
display: block;
float: left;
height: 15px;
background: #999;
text-align: center;
padding: 20px 30px 0 20px;
position: relative;
margin: 0 10px 0 0;
font-size: 18px;
text-decoration: none;
color: #fff;
line-height: 1px;
cursor:default;
}

#crumbs ul li a:after {
content: "";
position: absolute; right: -17px; top: 0;
border-top: 17px solid transparent;
border-bottom: 17px solid transparent;
border-left: 17px solid #999;
z-index: 1;
}
#crumbs ul li a:before {
content: "";
border-top: 17px solid transparent;
border-bottom: 17px solid transparent;
border-left: 17px solid #fff;
position: absolute; left: 0; top: 0;
}

#crumbs ul li {
display:inline;
}

#crumbs ul li a:hover {
background: #779519;
}
#crumbs ul li a:hover:after {
border-left-color: #779519;
}


#crumbs ul li:first-child a {
border-top-left: 10px; border-bottom-left: 10px;
}
#crumbs ul li:first-child a:before {
display: none;
}

#crumbs ul li:last-child a {
padding-right: 80px;
border-top-right: 10px; border-bottom-right: 10px;
}
#crumbs ul li:last-child a:after {
display: none;
}
<div id="crumbs">
<ul>
<li><a href="#">Tipo de Bilhete / Zona</a></li>
<li><a href="#">Sector</a></li>
<li><a href="#">Lugar</a></li>


</ul>
</div>

最佳答案

我只是更改了 :hover分入color允许您添加 class="color"<li> 之一的

body {
font-family: Arial, Helvetica, sans-serif;
}
#crumbs ul li a {
display: block;
float: left;
height: 15px;
background: #999;
text-align: center;
padding: 20px 30px 0 20px;
position: relative;
margin: 0 10px 0 0;
font-size: 18px;
text-decoration: none;
color: #fff;
line-height: 1px;
cursor: default;
}
#crumbs ul li a:after {
content: "";
position: absolute;
right: -17px;
top: 0;
border-top: 17px solid transparent;
border-bottom: 17px solid transparent;
border-left: 17px solid #999;
z-index: 1;
}
#crumbs ul li a:before {
content: "";
border-top: 17px solid transparent;
border-bottom: 17px solid transparent;
border-left: 17px solid #fff;
position: absolute;
left: 0;
top: 0;
}
#crumbs ul li {
display: inline;
}
#crumbs ul li a.color {
background: #779519;
}
#crumbs ul li a.color:after {
border-left-color: #779519;
}
#crumbs ul li:first-child a {
border-top-left: 10px;
border-bottom-left: 10px;
}
#crumbs ul li:first-child a:before {
display: none;
}
#crumbs ul li:last-child a {
padding-right: 80px;
border-top-right: 10px;
border-bottom-right: 10px;
}
#crumbs ul li:last-child a:after {
display: none;
}
<div id="crumbs">
<ul>
<li><a href="#">Tipo de Bilhete / Zona</a>
</li>
<li><a href="#" class="color">Sector</a>
</li>
<li><a href="#">Lugar</a>
</li>
</ul>
</div>

关于css - 如何显示与其他元素颜色不同的面包屑元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27190294/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com