学堂 学堂 学堂公众号手机端

CSS按钮hover怎么使用,怎样实现炫酷丰富的效果

lewis 1年前 (2024-03-27) 阅读数 7 #技术
本篇内容介绍了“CSS按钮hover怎么使用,怎样实现炫酷丰富的效果”的有关知识,在实际项目的操作过程或是学习过程中,不少人都会遇到这样的问题,接下来就让小编带大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!


CSS按钮hover方法怎么用呢?下面是CSS Button按钮8种漂亮的hover效果示例,让大家在网站开发中学会如何使用css hover方法打造一个让人眼前一亮的hover效果,请看介绍。

一:CSS hover发送效果,hover火箭发射效果

HTML:

<divid="send-btn">
<button>
//这里是一个svg箭头的占位
Send
</button>
</div>

CSS:

#send-btn{
display:flex;
align-items:center;
justify-content:center;
height:100vh;
}

button{
background:#5f55af;
border:0;
border-radius:5px;
padding:10px30px10px20px;
color:white;
text-transform:uppercase;
font-weight:bold;
}

buttonsvg{
display:inline-block;
vertical-align:middle;
padding-right:5px;
}

button:hoversvg{
animation:fly2sease1;
}

@keyframesfly{
0%{
transform:translateX(0%);
}

50%{
transform:translateX(300%);
}

100%{
transform:translateX(0);
}
}

GIF效果展示:


二:CSS hover霓虹灯效果

HTML:

<divid="neon-btn">
<buttonclass="btnone">Hoverme</button>
<buttonclass="btntwo">Hoverme</button>
<buttonclass="btnthree">Hoverme</button>
</div>

CSS:

#neon-btn{
display:flex;
align-items:center;
justify-content:space-around;
height:100vh;
background:#031628;
}

.btn{
border:1pxsolid;
background-color:transparent;
text-transform:uppercase;
font-size:14px;
padding:10px20px;
font-weight:300;
}

.one{
color:#4cc9f0;
}

.two{
color:#f038ff;
}

.three{
color:#b9e769;
}

.btn:hover{
color:white;
border:0;
}

.one:hover{
background-color:#4cc9f0;
-webkit-box-shadow:10px10px99px6pxrgba(76,201,240,1);
-moz-box-shadow:10px10px99px6pxrgba(76,201,240,1);
box-shadow:10px10px99px6pxrgba(76,201,240,1);
}

.two:hover{
background-color:#f038ff;
-webkit-box-shadow:10px10px99px6pxrgba(240,56,255,1);
-moz-box-shadow:10px10px99px6pxrgba(240,56,255,1);
box-shadow:10px10px99px6pxrgba(240,56,255,1);
}

.three:hover{
background-color:#b9e769;
-webkit-box-shadow:10px10px99px6pxrgba(185,231,105,1);
-moz-box-shadow:10px10px99px6pxrgba(185,231,105,1);
box-shadow:10px10px99px6pxrgba(185,231,105,1);
}

GIF效果展示:

三:CSS hover边框效果

HTML:

<divid="draw-border">
<button>Hoverme</button>
</div>

CSS:

#draw-border{
display:flex;
align-items:center;
justify-content:center;
height:100vh;
}

button{
border:0;
background:none;
text-transform:uppercase;
color:#4361ee;
font-weight:bold;
position:relative;
outline:none;
padding:10px20px;
box-sizing:border-box;
}

button::before,button::after{
box-sizing:inherit;
position:absolute;
content:'';
border:2pxsolidtransparent;
width:0;
height:0;
}

button::after{
bottom:0;
right:0;
}

button::before{
top:0;
left:0;
}

button:hover::before,button:hover::after{
width:100%;
height:100%;
}

button:hover::before{
border-top-color:#4361ee;
border-right-color:#4361ee;
transition:width0.3sease-out,height0.3sease-out0.3s;
}

button:hover::after{
border-bottom-color:#4361ee;
border-left-color:#4361ee;
transition:border-color0sease-out0.6s,width0.3sease-out0.6s,height0.3sease-out1s;
}

GIF效果展示:

四:CSS hover圆形效果

HTML:

<divid="circle-btn">
<divclass="btn-container">
//这里有一个svg元素
<button>Hoverme</button>
</div>
</div>

CSS:

#circle-btn{
display:flex;
align-items:center;
justify-content:center;
height:100vh;
}

.btn-container{
position:relative;
}

button{
border:0;
border-radius:50px;
color:white;
background:#5f55af;
padding:15px20px16px60px;
text-transform:uppercase;
background:linear-gradient(toright,#f7258550%,#5f55af50%);
background-size:200%100%;
background-position:rightbottom;
transition:all2sease;
}

svg{
background:#f72585;
padding:8px;
border-radius:50%;
position:absolute;
left:0;
top:0%;
}

button:hover{
background-position:leftbottom;
}

GIF效果展示:

五:CSS hover圆角变换效果

HTML:

<divid="border-btn">
<button>Hoverme</button>
</div>

CSS:

#border-btn{
display:flex;
align-items:center;
justify-content:center;
height:100vh;
}

button{
border:0;
border-radius:10px;
background:#2ec4b6;
text-transform:uppercase;
color:white;
font-size:16px;
font-weight:bold;
padding:15px30px;
outline:none;
position:relative;
transition:border-radius3s;
-webkit-transition:border-radius3s;
}

button:hover{
border-bottom-right-radius:50px;
border-top-left-radius:50px;
border-bottom-left-radius:10px;
border-top-right-radius:10px;
}

GIF效果展示:

六:CSS hover冰冻效果

HTML:

<divid="frozen-btn">
<buttonclass="green">Hoverme</button>
<buttonclass="purple">Hoverme</button>
</div>

CSS:

#frozen-btn{
display:flex;
align-items:center;
justify-content:center;
height:100vh;
}

button{
border:0;
margin:20px;
text-transform:uppercase;
font-size:20px;
font-weight:bold;
padding:15px50px;
border-radius:50px;
color:white;
outline:none;
position:relative;
}

button:before{
content:'';
display:block;
background:linear-gradient(toleft,rgba(255,255,255,0)50%,rgba(255,255,255,0.4)50%);
background-size:210%100%;
background-position:rightbottom;
height:100%;
width:100%;
position:absolute;
top:0;
bottom:0;
right:0;
left:0;
border-radius:50px;
transition:all1s;
-webkit-transition:all1s;
}

.green{
background-image:linear-gradient(toright,#25aae1,#40e495);
box-shadow:04px15px0rgba(49,196,190,0.75);
}

.purple{
background-image:linear-gradient(toright,#6253e1,#852D91);
box-shadow:04px15px0rgba(236,116,149,0.75);
}

.purple:hover:before{
background-position:leftbottom;
}

.green:hover:before{
background-position:leftbottom;
}

GIF效果展示:

七:CSS hover闪亮效果

HTML:

<divid="shiny-shadow">
<button><span>Hoverme</span></button>
</div>

CSS:

#shiny-shadow{
display:flex;
align-items:center;
justify-content:center;
height:100vh;
background:#1c2541;
}

button{
border:2pxsolidwhite;
background:transparent;
text-transform:uppercase;
color:white;
padding:15px50px;
outline:none;
overflow:hidden;
position:relative;
}

span{
z-index:20;
}

button:after{
content:'';
display:block;
position:absolute;
top:-36px;
left:-100px;
background:white;
width:50px;
height:125px;
opacity:20%;
transform:rotate(-45deg);
}

button:hover:after{
left:120%;
transition:all600mscubic-bezier(0.3,1,0.2,1);
-webkit-transition:all600mscubic-bezier(0.3,1,0.2,1);
}

GIF效果展示:


八:CSS hover加载效果

HTML:

<divid="loading-btn">
<button><span>Hoverme</span></button>
</div>

CSS:

#loading-btn{
display:flex;
align-items:center;
justify-content:center;
height:100vh;
}

button{
background:transparent;
border:0;
border-radius:0;
text-transform:uppercase;
font-weight:bold;
font-size:20px;
padding:15px50px;
position:relative;
}

button:before{
transition:all0.8scubic-bezier(0.7,-0.5,0.2,2);
content:'';
width:1%;
height:100%;
background:#ff5964;
position:absolute;
top:0;
left:0;
}

buttonspan{
mix-blend-mode:darken;
}

button:hover:before{
background:#ff5964;
width:100%;
}

GIF效果展示:



关于“CSS按钮hover怎么使用,怎样实现炫酷丰富的效果”就介绍到这了,如果大家觉得不错可以参考了解看看,如果想要了解更多,欢迎关注博信,小编每天都会为大家更新不同的知识。
版权声明

本文仅代表作者观点,不代表博信信息网立场。

热门