logo

Blur Buttons

Lien d’origine: https://codepen.io/caesura/pen/RrWQKX

HTML:

<section class="blur-buttons">
<div class="fond-blur" id="blur_background">
<div class="btn" id="btn-1"><span>Blur on hover</span></div>
<div class="btn" id="btn-2"><span>Clear on hover</span></div>
</div>
</section>

CSS:

.fond-blur{
padding: 15%;
}
.blur-buttons #blur_background {
width: 100%;
height: 100%;
position: relative;
padding: 5% auto;
text-align: center;
background: url("https://images.unsplash.com/photo-1458682625221-3a45f8a844c7?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=71fe1cccc16ab8dbd431de076c68802b") no-repeat center;
background-size: cover;
}
.blur-buttons .btn {
width: 280px;
height: 56px;
display: inline-block;
position: relative;
top: 20%;
margin: 16px;
overflow: hidden;
background: transparent;
border: 2px solid white;
color: white;
font-family: Roboto, sans-serif;
font-size: 18px;
letter-spacing: 0.8px;
text-transform: uppercase;
cursor: pointer;
-webkit-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
-webkit-transform: translate3d(0, 0, 0);
}
.blur-buttons .btn:before {
content: "";
padding: 100%;
top: -4px;
left: -4px;
right: -4px;
background: url("https://images.unsplash.com/photo-1458682625221-3a45f8a844c7?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=71fe1cccc16ab8dbd431de076c68802b") no-repeat;
background-size: cover;
background-attachment: fixed;
background-position: 50%;
-webkit-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
-webkit-transform: translate3d(0, 0, 0) scale(0);
}
.blur-buttons .btn span {
position: absolute;
top: 50%;
right: 0;
left: 0;
transform: translateY(-50%);
z-index: 9;
}
.blur-buttons .btn#btn-1:before {
transition: all 0.3s ease;
}
.blur-buttons .btn#btn-1:hover:before {
-webkit-filter: blur(4px);
filter: blur(4px);
}
.blur-buttons .btn#btn-2:before {
transition: all 0.3s ease;
-webkit-filter: blur(4px);
filter: blur(4px);
}
.blur-buttons .btn#btn-2:hover:before {
-webkit-filter: blur(0);
filter: blur(0);
}