有没有办法background-position取出百分比值?目前我的按钮仅适用于一个明确的价值观width和background-position.
body {
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
}
.button {
display: flex;
justify-content: center;
align-items: center;
text-decoration: none;
color: white;
font-weight: bold;
width: 350px;
height: 50px;
border: 1px solid green;
transition: background 0.5s;
background-repeat: no-repeat;
background-image: linear-gradient(to left, #2484c6, #1995c8 51%, #00bbce), linear-gradient(to right, #2484c6 0%, #1995c8 51%, #00bbce 76%);
}
.button-pixel {
background-position: -350px 0px, 0px 0px;
}
.button-pixel:hover {
background-position: 0px 0px, 350px 0px;
}
.button-percentage …Run Code Online (Sandbox Code Playgroud)动画重置后,动画中会出现明显的中断。
这是我所拥有的:
@keyframes AnimationName {
0% {
background-position: 100% 0%
}
100% {
background-position: 0% 0%
}
}
.myanimation {
width: 50px;
height: 150px;
background: repeating-linear-gradient(-45deg, #43ABC9, #43ABC9 7px, #369ebc 7px, #369ebc 14px);
animation: AnimationName 2s linear infinite;
background-size: 200% 200%;
}Run Code Online (Sandbox Code Playgroud)
<div class="myanimation"></div>Run Code Online (Sandbox Code Playgroud)
如何使它平滑且不引人注意?