← Каталог
CSS-анимации — готовые эффекты — Кнопка с hover и focus (transition)
Фрагмент из «CSS-анимации — готовые эффекты»: Кнопка с hover и focus (transition).
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Кнопка hover</title>
<style>
body {
margin: 0;
min-height: 100dvh;
display: grid;
place-items: center;
font-family: system-ui, sans-serif;
background: #fafafa;
}
.btn {
padding: 0.75rem 1.5rem;
border: none;
border-radius: 10px;
background: #2563eb;
color: #fff;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
background: #1d4ed8;
}
.btn:focus-visible {
outline: 3px solid #93c5fd;
outline-offset: 2px;
}
.btn:active {
transform: translateY(0);
box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
</style>
</head>
<body>
<button type="button" class="btn">Отправить</button>
</body>
</html> <!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Кнопка hover</title>
<style>
body {
margin: 0;
min-height: 100dvh;
display: grid;
place-items: center;
font-family: system-ui, sans-serif;
background: #fafafa;
}
.btn {
padding: 0.75rem 1.5rem;
border: none;
border-radius: 10px;
background: #2563eb;
color: #fff;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
background: #1d4ed8;
}
.btn:focus-visible {
outline: 3px solid #93c5fd;
outline-offset: 2px;
}
.btn:active {
transform: translateY(0);
box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
</style>
</head>
<body>
<button type="button" class="btn">Отправить</button>
</body>
</html>