Mở đầu
Xin chào các bạn, hôm nay Star Nhân IT sẽ hướng dẫn các bạn cách tạo button có hiệu ứng hover tuyệt đẹp mà mình tìm được trên codepen.io và chia sẻ lại cho các bạn, button này nhìn rất ưa mắt và khi bạn rê chuột vào sẽ có những hiệu ứng mà chắc chắn bạn không thể bỏ qua nó được đâu.
Hướng dẫn cách làm
Đầu tiên bạn thêm đoạn CSS này vào trước thẻ ]]></b:skin :
@import url(https://fonts.googleapis.com/css?family=Open+Sans);Tiếp theo bạn sẽ có 3 kiểu button, bạn chỉ cần lấy HTML để dưới mỗi button và chuyển qua soạn thảo HTML đặt vào và chỉnh sửa lại là được :
*, *::before, *::after {
box-sizing: border-box;
}
span.title {
margin: 0 auto;
color: #BBB;
font-family: 'Open Sans', sans-serif;
font-size: 0.85rem;
text-align: center;
display: block;
}
.basicBox, .swiggleBox, .checkBox {
width: 130px;
height: 65px;
margin: 15px auto;
color: #4274D3;
font-family: 'Open Sans', sans-serif;
font-size: 1.15rem;
line-height: 65px;
text-transform: uppercase;
text-align: center;
position: relative;
cursor: pointer;
}
svg {
position: absolute;
top: 0;
left: 0;
}
svg rect, svg path, svg polyline {
fill: none;
stroke: #4274D3;
stroke-width: 1;
}
.basicBox:hover svg rect, .swiggleBox:hover svg path, .checkBox:hover svg polyline {
stroke: #4274D3;
}
/* Basic Box */
svg rect {
stroke-dasharray: 400, 0;
-webkit-transition: all 0.8s ease-in-out;
-moz-transition: all 0.8s ease-in-out;
-ms-transition: all 0.8s ease-in-out;
-o-transition: all 0.8s ease-in-out;
}
.basicBox:hover svg rect {
stroke-width: 3;
stroke-dasharray: 35, 245;
stroke-dashoffset: 38;
-webkit-transition: all 0.8s ease-in-out;
-moz-transition: all 0.8s ease-in-out;
-ms-transition: all 0.8s ease-in-out;
-o-transition: all 0.8s ease-in-out;
}
/* Swiggle Box */
svg path {
stroke-dasharray: 265, 0;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
}
.swiggleBox:hover svg path {
stroke-width: 3;
stroke-dasharray: 0, 350;
stroke-dashoffset: 20;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
}
/* Check Box */
.checkBox {
/* Add Padding Left To Center Text */
}
.checkBox svg {
/* Presentation Purposes */
margin-left: -10px;
}
.checkBox svg rect, .checkBox svg polyline {
fill: none;
stroke: #4274D3;
stroke-width: 1;
-webkit-transition: all 0.8s ease-in-out;
-moz-transition: all 0.8s ease-in-out;
-ms-transition: all 0.8s ease-in-out;
-o-transition: all 0.8s ease-in-out;
}
.checkBox:hover svg rect {
stroke-width: 2;
-webkit-transition: all 0.8s ease-in-out;
-moz-transition: all 0.8s ease-in-out;
-ms-transition: all 0.8s ease-in-out;
-o-transition: all 0.8s ease-in-out;
}
.checkBox:hover svg polyline {
stroke-width: 2;
-webkit-transition: all 0.8s ease-in-out;
-moz-transition: all 0.8s ease-in-out;
-ms-transition: all 0.8s ease-in-out;
-o-transition: all 0.8s ease-in-out;
}
.checkBox svg .button {
stroke-dasharray: 400px, 0;
}
.checkBox:hover svg .button {
stroke-dasharray: 0, 400px;
stroke-dashoffset: 33px;
}
/* Check Mark Effect */
.box, .checkMark {
opacity: 0;
}
.checkBox:hover .box {
-webkit-animation: boxDisplay 0.2s forwards;
-moz-animation: boxDisplay 0.2s forwards;
-ms-animation: boxDisplay 0.2s forwards;
-o-animation: boxDisplay 0.2s forwards;
animation: boxDisplay 0.2s forwards;
-webkit-animation-delay: 0.65s;
-moz-animation-delay: 0.65s;
-ms-animation-delay: 0.65s;
-o-animation-delay: 0.65s;
animation-delay: 0.65s;
}
.checkBox:hover .checkMark {
-webkit-animation: checkDisplay 0.2s forwards;
-moz-animation: checkDisplay 0.2s forwards;
-ms-animation: checkDisplay 0.2s forwards;
-o-animation: checkDisplay 0.2s forwards;
animation: checkDisplay 0.2s forwards;
-webkit-animation-delay: 1s;
-moz-animation-delay: 1s;
-ms-animation-delay: 1s;
-o-animation-delay: 1s;
animation-delay: 1s;
}
/* Check Box Display */
@-webkit-keyframes boxDisplay {
0% { opacity: 0; }
100% { opacity: 1; }
}
@-moz-keyframes boxDisplay {
0% { opacity: 0; }
100% { opacity: 1; }
}
@-ms-keyframes boxDisplay {
0% { opacity: 0; }
100% { opacity: 1; }
}
@-o-keyframes boxDisplay {
0% { opacity: 0; }
100% { opacity: 1; }
}
@keyframes boxDisplay {
0% { opacity: 0; }
100% { opacity: 1; }
}
/* Check Mark Display */
@-webkit-keyframes checkDisplay {
0% { opacity: 0; }
100% { opacity: 1; }
}
@-moz-keyframes checkDisplay {
0% { opacity: 0; }
100% { opacity: 1; }
}
@-ms-keyframes checkDisplay {
0% { opacity: 0; }
100% { opacity: 1; }
}
@-o-keyframes checkDisplay {
0% { opacity: 0; }
100% { opacity: 1; }
}
@keyframes checkDisplay {
0% { opacity: 0; }
100% { opacity: 1; }
}
Kiểu 1 :
Hover
HTML :
<span class="title">Basic Box Hover</span>
<div class="basicBox">
Hover
<svg width="130" height="65" viewBox="0 0 130 65" xmlns="http://www.w3.org/2000/svg">
<rect x='0' y='0' fill='none' width='130' height='65'/>
</svg>
</div>
Kiểu 2:
Swiggle Box Hover
Hover
HTML :
<span class="title">Swiggle Box Hover</span>
<div class="swiggleBox">
Hover
<svg width="130" height="65" viewBox="0 0 130 65" xmlns="http://www.w3.org/2000/svg">
<path d="M0.6,0.5c0,5.4,0,61.5,0,61.5s4.5,5.4,9.9,0c5.4-5.4,9.9,0,9.9,0s4.5,5.4,9.9,0c5.4-5.4,9.9,0,9.9,0
s4.5,5.4,9.9,0c5.4-5.4,9.9,0,9.9,0s4.5,5.4,9.9,0c5.4-5.4,9.9,0,9.9,0s4.5,5.4,9.9,0c5.4-5.4,9.9,0,9.9,0s4.5,5.4,9.9,0
c5.4-5.4,9.9,0,9.9,0s4.5,5.4,9.9,0c0,0,0-56.1,0-61.5H0.6z"/>
</svg>
</div>
Kiểu 3 :
Check Box Hover
Hover
HTML :
<span class="title">Check Box Hover</span>
<div class="checkBox">
Hover
<svg width="140" height="65" viewBox="0 0 140 65" xmlns="http://www.w3.org/2000/svg">
<rect x="10" class="button" width="128.8" height="63.9"/>
<rect x="0" y="22.5" class="box" width="20" height="20"/>
<polyline class="checkMark" points="4.5,32.6 8.7,36.8 16.5,29.1"/>
</svg>
</div>


Đẹp đó em độc và lạ :v
Trả lờiXóa<3 Tks a Quốc dz :3
XóaHay
Trả lờiXóaTks ô <3
Xóabác sửa liên kết lại giúp nhé
Trả lờiXóahttps://www.theloi.xyz/
Rồi nha ô <3
Xóa- chất lừ :v
Trả lờiXóaTks bác <3
XóaTemps này của anh chất nè :v cái kiểu tổng hợp luôn í :v Nhân tiện , post của anh hay lắm :V độc , lạ :v
Trả lờiXóa^^ Tks e nhé <3
XóaHay
Trả lờiXóaTks <3
XóaNhìn chất đó em :v
Trả lờiXóa:v Đương nhiên rầu anh
Xóa