gpt4 book ai didi

css - 在伪元素 "Arrow"处定位 CSS 转换?

转载 作者:太空宇宙 更新时间:2023-11-03 17:27:54 25 4
gpt4 key购买 nike

我有一个底部带有“箭头”的 DIV,这与漫画书中的对话泡泡不同,它出现在悬停状态下:

enter image description here

箭头是用 :after:before 伪元素创建的。

我有一个边框颜色和框阴影的悬停过渡。

我的问题是“箭头”只是“出现”。没有像其他元素那样褪色,但我不知道如何瞄准“箭头”。 “全部”看起来也不对。

理想情况下,我希望在箭头上有一个延迟和一个简单的淡入淡出或删除。

这是 CSS:

.item-selector-button {
position: relative;
text-align: center;
cursor: pointer;
border: 1px solid #cecece;
padding: 15px;
border-radius: 0;
color: #000;
width: 160px;
height: 120px;
transition: all ease-in-out 0.1s, box-shadow ease-in-out 0.1s;
}

.item-selector-button .title {
color: #3e53a4;
font-size: 12px;
margin: 0;
padding-top: -3px;
font-family: "PrecisionSans_W_Md", "Helvetica Neue", Arial, sans-serif;
}

.item-selector-button .divider {
height: 1px;
width: 20px;
background-color: #cecece;
margin: 4px auto 10px;
}

.item-selector-button .image {
background: #fff url("../images/box.png") center center no-repeat;
width: 64px;
height: 57px;
margin: 4px auto;
}

.item-selector-button:hover, .item-selector-button.hover {
padding: 14px;
}

.item-selector-button:hover:after, .item-selector-button.hover:after {
content: "";
position: absolute;
bottom: -12px;
left: 68px;
border-width: 12px 12px 0;
border-style: solid;
border-color: #fff transparent;
transition-delay: 0.3s;
}

.item-selector-button:hover:before, .item-selector-button.hover:before {
content: "";
position: absolute;
bottom: -15px;
left: 65px;
border-width: 15px 15px 0;
border-style: solid;
border-color: #3e53a4 transparent;
transition-delay: 0.3s;
}

.item-selector-button:active, .item-selector-button.active {
border-width: 2px;
border-color: #3e53a4;
background-color: #3e53a4;
}

.item-selector-button:active:before, .item-selector-button.active:before {
content: "";
position: absolute;
bottom: -15px;
left: 65px;
border-width: 15px 15px 0;
border-style: solid;
border-color: #3e53a4 transparent;
transition-delay: 0.3s;
}

.item-selector-button:active .title, .item-selector-button.active .title {
color: #fff;
}

.item-selector-button:active .divider, .item-selector-button.active .divider {
background-color: #fff;
}

.item-selector-button:active .image, .item-selector-button.active .image {
background-color: #3e53a4;
}

.item-selector-button:active:hover, .item-selector-button.active:hover {
padding: 15px;
box-shadow: none;
}

.item-selector-button:active:hover:after, .item-selector-button.active:hover:after {
content: "";
position: absolute;
bottom: -12px;
left: 68px;
border-width: 12px 12px 0;
border-style: solid;
border-color: #3e53a4 transparent;
transition-delay: 0.3s;
}

.item-selector-button.disabled {
pointer-events: none;
cursor: not-allowed;
}

.item-selector-button.disabled .title {
color: #c3c3c3;
}

.item-selector-button.disabled .image {
background-image: url("../images/box-disabled.png");
}

.item-selector-button.disabled:hover {
padding: 15px;
border: 1px solid #cecece;
box-shadow: none;
}

最佳答案

悬停元素上只有伪元素,所以没有什么可以从/到过渡。您需要在非悬停状态元素上添加伪元素。

示例转换可见性:

.item-selector-button:before {
.arrow-inside(...);
transition:all 5s ease;
transition-delay: 0.3s;
visibility:hidden;
}

.item-selector-button:after {
.arrow-outside(...);
transition:all 5s ease;
transition-delay: 0.3s;
visibility:hidden;
}

.item-selector-button:hover:before {
visibility:visible;
}

.item-selector-button:hover:after {
visibility:visible;
}

关于css - 在伪元素 "Arrow"处定位 CSS 转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31124724/

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