【发布时间】:2021-05-26 19:15:02
【问题描述】:
我用变换和过渡构建了这个按钮。但是有一个小问题我无法弄清楚。当我想悬停链接时,我必须使用 span 来缩放它们。每个跨度有 25% 的链接宽度。但在 3 号和 4 号跨度之间有一个很小的空间。
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-family: sans-serif;
}
a {
font-size: 25px;
font-weight: 700;
display: block;
text-decoration: none;
border: 3px solid rgb(84, 7, 136);
color: rgb(84, 7, 136);
padding: 50px 80px;
position: relative;
overflow: hidden;
}
h2 {
text-align: center;
}
body > div {
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.effect11 a span {
position: absolute;
top: 0;
left: 0;
width: 25%;
height: 100%;
background-color: black;
transform: scaleY(0);
transform-origin: top;
transition: all 1s;
z-index: -1;
}
.effect11 a {
transition: all 1s;
}
.effect11 a span:nth-child(1) {
left: 0;
transition-delay: 0.15s;
}
.effect11 a span:nth-child(2) {
left: 25%;
transition-delay: 0.3s;
}
.effect11 a span:nth-child(3) {
left: 50%;
transition-delay: 0.45s;
}
.effect11 a span:nth-child(4) {
left: 75%;
transition-delay: 0.6s;
}
.effect11 a:hover span {
transform: scaleY(1);
}
.effect11 a:hover {
color: white;
}
This is what happening that I don't want to appear (that little space)
【问题讨论】:
-
在 Windows 机器上的 Chrome 和 Firefox 中运行良好。你用的是什么浏览器?
-
很确定你的问题是你的文本“悬停我”。它弄乱了 列。
-
我在 chrome 和 firefox 上测试并得到相同的结果
标签: css css-transitions transform