Make Your HTML Buttons More Attractive With These CSS Animations
HTML
<button class="btn basic-hover">
BASIC HOVER
</button>
CSS
.btn, .btn:hover {
color: #fff;
}
.basic-hover {
background-color: #087f79;
transition: 0.2s;
}
.basic-hover:hover {
background-color: #e04f23;
transition: 0.2s;
}
HTML
<button class="btn dynamic-border-radius">
DYNAMIC BORDER RADIUS
</button>
CSS
.dynamic-border-radius {
background-color: #087f79;
transition: 0.2s;
border-radius: 0;
}
.dynamic-border-radius:hover {
background-color: #e04f23;
transition: 0.2s;
border-top-left-radius: 1rem;
border-bottom-right-radius: 1rem;
}
HTML
<button class="btn rubber-band">
RUBBER BAND
</button>
CSS
.btn, .btn:hover {
color: #fff;
}
.rubber-band {
position: relative;
background-color: transparent;
}
.rubber-band:before, .rubber-band:after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.rubber-band:before {
background-color: #087f79;
}
.rubber-band:after {
max-width: 0;
background-color: #e04f23;
transition: max-width 0.3s;
}
.rubber-band:hover:after {
animation-name: rubberBandButton;
animation-duration: 0.8s;
animation-timing-function: ease-in-out;
max-width: 100%;
}
@keyframes rubberBandButton {
0% {
max-width: 0%;
}
30% {
max-width: 50%;
}
80% {
max-width: 0%;
}
100% {
max-width: 100%;
}
}
HTML
<button class="btn slide-down">
SLIDE DOWN
</button>
CSS
.btn, .btn:hover {
color: #fff;
}
.slide-down {
position: relative;
background-color: transparent;
}
.slide-down:before, .slide-down:after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.slide-down:before {
background-color: #087f79;
}
.slide-down:after {
max-height: 0;
background-color: #e04f23;
transition: max-height 0.25s ease-in;
}
.slide-down:hover:after {
max-height: 100%;
}
HTML
<button class="btn bubble">
BUBBLE
</button>
CSS
.btn, .btn:hover {
color: #fff;
}
.bubble {
position: relative;
background-color: transparent;
overflow: hidden;
}
.bubble:before, .bubble:after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.bubble:before {
background-color: #087f79;
}
.bubble:after {
width: 100px;
height: 100px;
left: 50%;
background-color: #e04f23;
transform: scale(0) translate(-50%, -50%);
transition: transform 0.5s ease-in;
border-radius: 50%;
}
.bubble:hover:after {
transform: scale(1.5) translate(-50%, -50%);
}
HTML
<button class="btn border-first">
BORDER FIRST
</button>
CSS
.border-first {
position: relative;
background-color: transparent;
color: #e04f23;
transition: color 0.3s 0.2s;
}
.border-first:hover {
color: #fff;
transition: color 0.3s 0.2s;
}
.border-first:before, .border-first:after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
max-width: 0;
z-index: -1;
transition: max-width 0.3s, opacity 0.3s;
opacity: 0;
}
.border-first:before {
background-color: transparent;
border: 2px solid;
border-top-color: #e04f23;
border-bottom-color: #e04f23;
border-right-color: transparent;
border-left-color: transparent;
}
.border-first:after {
background-color: #e04f23;
border: 2px solid #e04f23;
transition-delay: 0.2s;
}
.border-first:hover:before, .border-first:hover:after {
max-width: 100%;
opacity: 1;
}
.border-first:hover:after {
transition-delay: 0.4s;
}