我想将菜单列表项的背景看作一个标签,如何在CSS中完成并在其旁边添加图标
CSS
#cdnavheader .activeMenuItem span {
background-position: 100% -145px;
color: #2d83ab;
padding: 12px;
background-repeat: no-repeat;
color: #fff;
background-color: #2d489b;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
答案 0 :(得分:1)
您还可以使用伪和变换:
a {
display: inline-block;/* fallback*/
position: relative;
overflow: hidden;
border-radius:5px 5px 0 0;
padding: 1em 3em 1em 2em;
}
a:before {
content: '';
position: absolute;
top: 0;
right: 0;
width: 120%;
height: 200%;
z-index: -1;
background: tomato;
border-radius:inherit;
transform: skew(35deg)
}
nav {
display: flex;
margin: 1em;
}

<nav><a href="#"> some link</a>
<a href="#"> some link</a>
<a href="#"> some link</a>
</nav>
&#13;
答案 1 :(得分:0)
使用带有大边框的零高度DIV:
.tab {
width: 100px;
height: 0px;
border-right: 20px solid transparent;
border-bottom: 20px solid green;
}
&#13;
<div class="tab"></div>
&#13;