DEMO
https://html5book.ru/examples/styling-buttons/demo-styling-button-1.html
---------------------
Пример 1.
Анимация при наведении достигается за счёт изменения позиции градиентной заливки.
Button
body {background: #d6eaf8}
a {
text-decoration: none;
outline: none;
display: inline-block;
color: white;
padding: 20px 30px;
margin: 10px 20px;
border-radius: 10px;
font-family: 'Montserrat', sans-serif;
text-transform: uppercase;
letter-spacing: 2px;
background-image: linear-gradient(to right, #9EEFE1 0%, #4830F0 51%, #9EEFE1 100%);
background-size: 200% auto;
box-shadow: 0 0 20px rgba(0,0,0,.1);
transition: .5s;
}
a:hover {background-position: right center;}
Пример 2.
Для псевдоэлементов изначально задана нулевая высота и ширина, которая сменяется на 100% при наведении. Блоки, генерируемые с помощью псевдоэлементов, прозрачные, для них заданы левая/верхняя и правая/нижняя границы, которые проявляются при наведении, создавая эффект прорисовки.
Button
html {height: 100%}
body {
background: linear-gradient(to top, #55EFCB 0%, #5BCAFF 100%);
height: 100%;
}
a {
text-decoration: none;
outline: none;
display: inline-block;
padding: 20px 30px;
margin: 10px 20px;
position: relative;
color: white;
border: 1px solid rgba(255,255,255,.4);
background: none;
font-weight: 300;
font-family: 'Montserrat', sans-serif;
text-transform: uppercase;
letter-spacing: 2px;
}
a:before,
a:after {
content: "";
position: absolute;
width: 0;
height: 0;
opacity: 0;
box-sizing: border-box;
}
a:before {
bottom: 0;
left: 0;
border-left: 1px solid white;
border-top: 1px solid white;
transition: 0s ease opacity .8s, .2s ease width .4s, .2s ease height .6s;
}
a:after {
top: 0;
right: 0;
border-right: 1px solid white;
border-bottom: 1px solid white;
transition: 0s ease opacity .4s, .2s ease width , .2s ease height .2s;
}
a:hover:before,
a:hover:after{
height: 100%;
width: 100%;
opacity: 1;
}
a:hover:before {transition: 0s ease opacity 0s, .2s ease height, .2s ease width .2s;}
a:hover:after {transition: 0s ease opacity .4s, .2s ease height .4s , .2s ease width .6s;}
a:hover {background: rgba(255,255,255,.2);}
Пример 3.
Кнопка при наведении меняет цвет фона и текста, тень блока и смещается вверх с помощью трансформации.
Button
body {background: url(https://html5book.ru/wp-content/uploads/2015/07/background39.png);}
a {
text-decoration: none;
outline: none;
display: inline-block;
width: 140px;
height: 45px;
line-height: 45px;
border-radius: 45px;
margin: 10px 20px;
font-family: 'Montserrat', sans-serif;
font-size: 11px;
text-transform: uppercase;
text-align: center;
letter-spacing: 3px;
font-weight: 600;
color: #524f4e;
background: white;
box-shadow: 0 8px 15px rgba(0,0,0,.1);
transition: .3s;
}
a:hover {
background: #2EE59D;
box-shadow: 0 15px 20px rgba(46,229,157,.4);
color: white;
transform: translateY(-7px);
}
Пример 4.
При наведении кнопка меняет положение градиента, а тень блока исчезает.
Button
body {background:url(https://html5book.ru/wp-content/uploads/2015/10/background54.png)}
a {
text-decoration: none;
outline: none;
display: inline-block;
padding: 12px 40px;
margin: 10px 20px;
border-radius: 30px;
background-image: linear-gradient(45deg, #6ab1d7 0%, #33d9de 50%, #002878 100%);
background-position: 100% 0;
background-size: 200% 200%;
font-family: 'Montserrat', sans-serif;
font-size: 24px;
font-weight: 300;
color: white;
box-shadow: 0 16px 32px 0 rgba(0,40,120,.35);
transition: .5s;
}
a:hover {
box-shadow: 0 0 0 0 rgba(0,40,120,0);
background-position: 0 0;
}
Пример 5.
При наведении градиентный блок, генерируемый с помощью псевдоэлемента, меняет высоту с нулевой на 100%.
Button
body {background: #1D1B26;}
.button-container a {
text-decoration: none;
outline: none;
color: white;
display: inline-block;
position: relative;
padding: 15px 30px;
border: 1px solid;
border-image: linear-gradient(180deg, #ff3000, #ed0200, #ff096c, #d50082);
border-image-slice: 1;
margin: 10px 20px; font-family: 'Montserrat', sans-serif;
text-transform: uppercase;
overflow: hidden;
letter-spacing: 2px;
transition: .8s cubic-bezier(.165,.84,.44,1);
}
.button-container a:before {
content: "";
position: absolute;
left: 0;
top: 0;
height: 0;
width: 100%;
z-index: -1;
color: white;
background: linear-gradient(180deg, #ff3000, #ed0200, #ff096c, #d50082);
transition: .8s cubic-bezier(.165,.84,.44,1);
}
a:hover {background: rgba(255,255,255,0);}
a:hover:before {
bottom: 0%;
top: auto;
height: 100%;
}
Пример 6.
При наведении кнопке добавляется анимация градиентной заливки.
Button
body {background: url(https://html5book.ru/wp-content/uploads/2015/10/background54.png)}
a {
text-decoration: none;
outline: none;
display: inline-block;
margin: 10px 20px;
padding: 15px 30px;
overflow: hidden;
border: 2px solid;
border-bottom-width: 4px;
font-family: 'Montserrat', sans-serif;
text-transform: uppercase;
font-weight: bold;
letter-spacing: 2px;
color: rgba(30,255,188,1);
background: rgba(255,255,255,1);
transition: color .3s, background .5s;
}
a:hover {
animation: stripes .75s infinite linear;
background: linear-gradient(45deg, rgba(30,255,188,1) 25%, rgba(255,255,255,1) 25%, rgba(255,255,255,1) 50%, rgba(30,255,188,1) 50%, rgba(30,255,188,1) 75%, rgba(255,255,255,1) 75%, rgba(255,255,255,1));
background-size: 10px 10px;
color: #FF50E5;
}
@keyframes stripes {
0% {background-position: 0 0;}
100% {background-position: 50px 0;}
}
Пример 7.
Фоновая заливка кнопки создана с помощью внутренней тени блока, которая меняет свой размер при наведении плюс добавляется внешняя тень блока.
Button
body {background: #A4DADA;}
a {
text-decoration: none;
outline: none;
display: inline-block;
padding: 15px 30px;
margin: 10px 20px;
border-radius: 10px;
box-shadow: 0 0 40px 40px #F137A6 inset, 0 0 0 0 #F137A6;
font-family: 'Montserrat', sans-serif;
font-weight: bold;
letter-spacing: 2px;
color: white;
transition: .15s ease-in-out;
}
a:hover {
box-shadow: 0 0 10px 0 #F137A6 inset, 0 0 10px 4px #F137A6;
color: #F137A6;
}
Пример 8.
Эффект «слайда» при наведении реализуется с помощью перемещения блоков-псевдоэлементов, один из которых расположен за левой границей кнопки, второй — за правой границей.
Button
body {background: #ebcacb;}
a {
text-decoration: none;
outline: none;
display: inline-block;
margin: 10px;
color: white;
box-shadow: 0 0 0 2px white;
padding: 20px 0;
width: 150px;
text-align: center;
text-transform: uppercase;
letter-spacing: 3px;
position: relative;
overflow: hidden;
}
span {
font-family: 'Montserrat', sans-serif;
position: relative;
z-index: 5;
}
a:before,
a:after {
content: "";
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
}
a:before{
transform: translateX(-100%);
background: white;
transition: transform .3s cubic-bezier(.55,.055,.675,.19);
}
a:after {
background: #413ad5;
transform: translateX(100%);
transition: transform .3s cubic-bezier(.16,.73,.58,.62) .3s;
}
a:hover:before,
a:hover:after {transform: translateX(0);}
Пример 9.
Вторая рамка сгенерирована с помощью псевдоэлемента, который дублирует кнопку и при наведении меняет цвет рамки, а также высоту и ширину.
Button
body {background: #1b2631;}
a {
text-decoration: none;
outline: none;
display: inline-block;
margin: 10px 20px;
padding: 10px 30px;
position: relative;
border: 2px solid #f1c40f;
color: #f1c40f;
font-family: 'Montserrat', sans-serif;
transition: .4s;
}
a:after {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
margin: auto;
border: 2px solid rgba(0,0,0,0);
transition: .4s;
}
.button-container a:hover:after {
border-color: #f1c40f;
width: calc(100% - 10px);
height: calc(100% + 10px);
}
Пример 10.
Псевдоэлемент, залитый градиентом, повёрнут на 45 градусов и смещен за левую границу кнопки. При наведении он перемещается за правую границу, создавая эффект блика.
Button
body {background: #ffbfbe;}
a {
text-decoration: none;
outline: none;
display: inline-block;
padding: 10px 30px;
margin: 10px 20px;
position: relative;
overflow: hidden;
border: 2px solid #fe6637;
border-radius: 8px;
font-family: 'Montserrat', sans-serif;
color: #fe6637;
transition: .2s ease-in-out;
}
a:before {
content: "";
background: linear-gradient(90deg, rgba(255,255,255,.1), rgba(255,255,255,.5));
height: 50px;
width: 50px;
position: absolute;
top: -8px;
left: -75px;
transform: skewX(-45deg);
}
a:hover {
background: #fe6637;
color: #fff;
}
a:hover:before {
left: 150px;
transition: .5s ease-in-out;
}