css 伪元过渡延迟

pqwbnv8z  于 2022-12-24  发布在  其他
关注(0)|答案(1)|浏览(119)

正如您在下面的代码中看到的,我使用伪元素after来获取菜单项的三角形形状。
为什么三角形对转换完全没有React?

.breadcrumb { 
    list-style: none; 
    overflow: hidden; 
    font: 18px Helvetica, Arial, Sans-Serif;
}

.breadcrumb li { 
    float: left;
}

.breadcrumb li a {
    color: white;
    text-decoration: none; 
    padding: 10px 0 10px 65px;
    background: brown;                   /* fallback color */
    background: hsla(34,85%,35%,1); 
    position: relative; 
    display: block;
    float: left;
}

.breadcrumb li a:after { 
    content: " "; 
    display: block; 
    width: 0; 
    height: 0;
    border-top: 50px solid transparent;           /* Go big on the size, and let overflow hide */
    border-bottom: 50px solid transparent;
    border-left: 30px solid hsla(34,85%,35%,1);
    position: absolute;
    top: 50%;
    margin-top: -50px; 
    left: 100%;
    z-index: 2; 
}

.breadcrumb li:first-child a {
    padding-left: 10px;
}

.breadcrumb li:nth-child(2) a       { background:        hsla(34,85%,45%,1); }
.breadcrumb li:nth-child(2) a:after { border-left-color: hsla(34,85%,45%,1); }
.breadcrumb li:nth-child(3) a       { background:        hsla(34,85%,55%,1); }
.breadcrumb li:nth-child(3) a:after { border-left-color: hsla(34,85%,55%,1); }
.breadcrumb li:nth-child(4) a       { background:        hsla(34,85%,65%,1); }
.breadcrumb li:nth-child(4) a:after { border-left-color: hsla(34,85%,65%,1); }
.breadcrumb li:nth-child(5) a       { background:        hsla(34,85%,75%,1); }
.breadcrumb li:nth-child(5) a:after { border-left-color: hsla(34,85%,75%,1); }

.breadcrumb li a:hover { background: hsla(34,85%,25%,1); transition-delay:.3s; }
.breadcrumb li a:hover:after { border-left-color: hsla(34,85%,25%,1) !important; transition: border-color 0.3s ; }
<ul class="breadcrumb">
    <li><a href="#">Home</a></li>
    <li><a href="#">Vehicles</a></li>
    <li><a href="#">Vans</a></li>
    <li><a href="#">Camper Vans</a></li>
</ul>

Credit: This menu taken from lesson on css-tricks.com with some editing.

fumotvh3

fumotvh31#

您的CSS中有一处打字错误,并且属性也不正确
您的代码

.breadcrumb li a:hover:after {
    border-left-color: hsla(34, 85%, 25%, 1) !important;
    transition: borded-color 0.3s;
}

应该是这样

.breadcrumb li a:hover:after {
    border-left-color: hsla(34, 85%, 25%, 1) !important;
    transition-delay: 0.3s;
}

JSfiddle Demo

相关问题