【发布时间】:2021-10-10 13:17:30
【问题描述】:
我一直在为这个问题撞墙。 我尝试使用这行代码使用 Elementor 使用 CSS 创建悬停效果的下划线。我已经尝试使用按钮小部件和文本编辑器小部件,但似乎根本无法让它工作。我错过了什么? 任何帮助都会非常有帮助。
谢谢
:
.underline {
display: inline;
position: relative;
overflow: hidden;
}
.underline:after {
content: "";
position: absolute;
z-index: -1;
left: 0;
right: 100%;
bottom: -5px;
background: #000;
height: 4px;
transition-property: left right;
transition-duration: 0.3s;
transition-timing-function: ease-out;
}
.underline:hover:after,
.underline:focus:after,
.underline:active:after {
right: 0;
}
【问题讨论】:
-
欢迎来到 Stack Overflow!寻求代码帮助的问题必须包括在问题本身最好是在Stack Snippet 中重现它所需的最短代码。见How to create a Minimal, Reproducible Example
-
也就是说不要向左或向右过渡,将宽度从 100% 过渡到 0。