#html #css3
Как сделать градиент на кнопку и задать градиенту вечную анимацию?
-Сделать градиент получилось, но заставить его двигаться не выходит...подскажите
где я допустил ошибку?
#header-button {
font-size: 12px;
font-weight: bold;
height: 50px;
width: 171px;
background-color: #998675;
outline: 0;
border: 0;
border-radius: 5px;
border-bottom: 3px solid #736357;
cursor: pointer;
margin-top: 30px;
color: #fff;
background-image: linear-gradient(-45deg, #998675 50%, #fff);
-webkit-animation: gradient 3s linear infinite;
animation: gradient 3s linear infinite;
}
@-webkit-keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%
}
}
Ответы
Ответ 1
Я бы реализовал так... #button-wrap { overflow: hidden; position: relative; height: 50px; width: 171px; } #header-button { position: absolute; height: 150px; width: 371px; outline: none; border: none; left: -200px; background-image: linear-gradient(-45deg, #998675 10%, #fff, #998675); animation: gradient 3s ease infinite; } @keyframes gradient { 0% { left: -200px; } 50% { left: 0px; } 100% { left: -200px; } } Вариант два, как я понял, вроде автор этого добивался.. #button-wrap { overflow: hidden; position: relative; height: 50px; width: 171px; } p { font-size: 12px; font-weight: bold; height: 100%; width: 100%; text-align: center; line-height: 2; color: #fff; position: absolute; } #header-button { position: absolute; height: 150px; width: 571px; outline: none; border: none; left: -400px; top: -100px; background-image: linear-gradient(-45deg, #998675 50%, #fff, #998675 55%); animation: gradient 3s ease infinite; } @keyframes gradient { 0% { left: -400px; top: -100px; } 100% { left: 0; top: -10px; } }
Комментариев нет:
Отправить комментарий