我已经创建了一个面包屑,您可以在此处查看代码http://jsfiddle.net/zgx5qcsx/
我需要一个CSS选择器才能将&:after&:之前的所有内容提供给除了最后一个li之外的所有内容但却无法解决这个问题 - 目前笨拙的我有:
li:first-child,
li:first-child + li
这并不理想,因为添加了更多步骤,我必须修改!
任何建议都将不胜感激
.breadcrumb
{
width: auto;
margin: 0;
padding: 0;
list-style: none;
border-bottom: 1px solid grey;
background-color: light-grey;
li
{
float: left;
margin: 0;
width: 33.33333333%;
a
{
&:link, &:visited
{
position: relative;
width: auto;
display: block;
// border-right: 1px solid grey;
@include x-rem(padding, 20px 20px 20px 50px);
text-decoration: none;
span
{
background-color: orange;
color: white;
}
}
}
}
li:first-child,
li:first-child + li
{
a
{
&:after
{
position: absolute;
top: 0;
right: -40px;
display: block;
content: "";
border-top: 29px solid transparent;
border-left: 30px solid light-grey;
border-bottom: 29px solid transparent;
border-right: 10px solid transparent;
z-index: 2;
}
&:before
{
position: absolute;
top: 0;
right: -41px;
display: block;
content: "";
border-top: 29px solid transparent;
border-left: 30px solid grey;
border-bottom: 29px solid transparent;
border-right: 10px solid transparent;
z-index: 1;
}
&.breadcrumb--active
{
background-color: white;
&:after
{
border-left: 30px solid white;
}
}
}
}
}
答案 0 :(得分:0)
就像我在li + li
之前所说的那样与li:first-child + li
相同(如果你想要的话,你可以在你的li里面做& + li
之类的事情)。这是我的解决方案 - 我更改了选择器并将所有内容对齐到左边。
.breadcrumb
{
width: auto;
margin: 0;
padding: 0;
list-style: none;
border-bottom: 1px solid grey;
background-color: lightgray; // watch out it's lightgray not light-grey :)
li
{
float: left;
margin: 0;
width: 33.33333333%;
a
{
&:link, &:visited
{
position: relative;
width: auto;
display: block;
// border-right: 1px solid grey;
@include x-rem(padding, 20px 20px 20px 50px);
text-decoration: none;
span
{
background-color: orange;
color: white;
}
}
&.breadcrumb--active //changed
{
background-color: white;
&:after
{
border-left: 30px solid grey;
z-index: 1;
}
}
}
}
li + li //changed
{
a
{
&:after
{
position: absolute;
top: 0;
left: 0; //changed
display: block;
content: "";
border-top: 29px solid transparent;
border-left: 30px solid lightgray;
border-bottom: 29px solid transparent;
border-right: 10px solid transparent;
z-index: 1; //changed
}
&:before
{
position: absolute;
top: 0;
left: -1px; //changed
display: block;
content: "";
border-top: 29px solid transparent;
border-left: 30px solid white; //changed
border-bottom: 29px solid transparent;
border-right: 10px solid transparent;
z-index: 2; //changed
}
}
}
}