Вход

Эффекты кнопок при наведении на HTML и CSS

Эффекты кнопок при наведении на HTML и CSS

В этой статье мы рассмотрим как создать эффекты кнопок при наведении на HTML и CSS

Чтобы привлечь внимание посетителей сайта можно использовать анимированные эффекты для различных элементов дизайна. В этой статье представлены эффекты для обычных кнопок.

В файле index.html представлены ссылки которые мы оформили как кнопки, добавив им соответствующие классы. Каждая кнопка имеет свою стилистику. Вам достаточно выбрать понравившийся эффект, скопировав класс у кнопки и правила css, которые ему соответствуют.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!DOCTYPE html>
<html lang="ru">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<title>Стилизация кнопок</title>
	<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
	<div class="main">
		<h2>Примеры эффектов кнопок при наведении</h2>
		<a href="#" class="btn1">Кнопка 1</a>
		<br>
		<a href="#" class="btn2">Кнопка 2</a>
		<br>
		<a href="#" class="btn3">Кнопка 3</a>
		<br>
		<a href="#" class="btn4">Кнопка 4</a>
		<br>
		<a href="#" class="btn5">Кнопка 5</a>
		<br>
		<a href="#" class="btn6">Кнопка 6</a>
		<br>
		<a href="#" class="btn7">Кнопка 7</a>
	</div>
</body>
</html>

Файл style.css с с правилами оформления кнопок:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
 
.main{
	width:1000px;
	margin:0 auto;
	text-align: center;
}
h2{
	text-align: center;
}
.btn1, .btn2, .btn3, .btn4, .btn5, .btn6, .btn7{
	background: #333 none repeat scroll 0 0;
    clear: both;
    color: #fff;
    display: block;
    font-weight: normal;
    height: 22px;
    margin: 0 auto;
    padding: 5px 10px;
    position: relative;
    text-align: center;
    text-decoration: none;
    transition: all 0.4s ease 0s;
    width: 160px;
    z-index: 1;
}
 
/* Кнопка 1 */
.btn1::before {
    content: "";
    height: 0;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: all 0.4s ease 0s;
}
.btn1:hover::before {
    background: #ff5b23 none repeat scroll 0 0;
    height: 100%;
    z-index: -1;
}
.btn1:hover{
	color: #fff;
}
 
/* Кнопка 2 */
.btn2::before {
    content: "";
    width: 0;
    left: 0;
    position: absolute;
    top: 0;
    bottom:0;
    transition: all 0.4s ease 0s;
}
.btn2:hover::before {
    background: #ff5b23 none repeat scroll 0 0;
    width: 100%;
    z-index: -1;
}
.btn2:hover{
	color: #fff;
}
 
/* Кнопка 3 */
.btn3::before {
    content: "";
    height: 0;
    left: 0;
    position: absolute;
    right: 0;
    bottom:0;
    transition: all 0.4s ease 0s;
}
.btn3:hover::before {
    background: #ff5b23 none repeat scroll 0 0;
    height: 5px;
    z-index: -1;
}
.btn3:hover{
	color:#fff;
}
 
/* Кнопка 4 */
.btn4::before {
    background: #ff5b23 none repeat scroll 0 0;
    box-sizing: content-box;
    content: " ";
    height: 100%;
    left: -1px;
    opacity: 0;
    padding: 1px;
    pointer-events: none;
    position: absolute;
    top: -1px;
    transform: scale(1.2);
    transition: transform 0.2s ease 0s, opacity 0.3s ease 0s;
    width: 100%;
    z-index: -1;
}
.btn4:hover::before {
    opacity: 1;
    transform: scale(1);
}
.btn4:hover{
	color: #fff;
}
 
/* Кнопка 5 */
.btn5{
	overflow: hidden;
}
.btn5::after {
    border-color: transparent #ff5b23 transparent transparent;
    right: 0;
    top: 0;
}
.btn5::before {
    border-color: transparent transparent transparent #ff5b23;
    bottom: 0;
    left: 0;
}
.btn5::before, .btn5::after {
    border-style: solid;
    border-width: 0;
    content: "";
    height: 0;
    position: absolute;
    transition: all 0.4s ease 0s;
    width: 0;
    z-index: -1;
}
.btn5:hover::after {
    border-width: 0 165px 165px 0;
}
 
.btn5:hover::before {
    border-width: 165px 0 0 165px;
}
 
/* Кнопка 6 */
.btn6::before {
    content: "";
    height: 5px;
    left: 0;
    position: absolute;
    bottom:0;
    width:0px;
    transition: all 0.4s ease 0s;
}
.btn6:hover::before {
    background: #ff5b23 none repeat scroll 0 0;
    width: 100%;
    z-index: -1;
}
.btn6:hover{
	color:#fff;
}
 
 
/* Кнопка 7 */
.btn7{
    overflow: hidden;
    display: inline-block;
}
.btn7::before {
    background: rgba(0, 0, 0, 0) linear-gradient(to right, rgba(255, 255, 255, 0) 0px, rgba(255, 255, 255, 0.3) 100%) repeat scroll 0 0;
    content: "";
    display: block;
    height: 100%;
    left: -75%;
    position: absolute;
    top: 0;
    transform: skewX(-25deg);
    width: 50%;
    z-index: 2;
    box-sizing:border-box;
}
.btn7:hover::before {
	animation: 0.75s ease 0s normal none 1 running shine;
}
@keyframes shine {
	100% {
	    left: 125%;
	}
}

Файлы для скачки:

6 июня 2017 /

3161 Views /

0 Comment
Ilya Web developer
Author

«Всегда пишите код так, будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете.»Martin Golding