<html>
<head>
<meta charset="UTF-8">
<title>鼠标悬停效果</title>
<style type="text/css">
*{
margin: 0
padding: 0
}
body{
background-color: #000
}
a{
width: 200px
height: 50px
display: block
text-align: center
line-height: 50px
text-decoration: none
position: absolute
top: 50%
left: 50%
transform: translate(-50%,-50%)
font-size: 24px
font-weight: bold
color: white
border: 1px solid white
overflow: hidden
}
a::before{
content: ""
position: absolute
top: 0
left: -100%
width: 100%
height: 100%
background-image: linear-gradient(60deg,transparent,rgba(146,148,248,.4),transparent)
transition: all 0.5s
}
a:hover::before{
left: 100%
}
a:hover{
box-shadow: 0 2px 10px 8px rgba(146,148,248,.4)
}
</style>
</head>
<body>
<a href="#">鼠标悬停效果</a>
</body>
</html>
CSS+HTML<悬停下划线效果>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body {
display: flex
height: 100vh
justify-content: center
align-items: center
}
ul {
padding: 0
margin: 0
list-style-type: none
}
ul li{
padding: 5px 0
}
ul li a {
position: relative
display: inline-block
text-decoration: none
color: #3a3a3a
/* 转大写 */
text-transform: uppercase
padding: 4px 0
transition: 0.5s
font-weight: bold
}
ul li a::after {
position: absolute
content: ""
width: 100%
height: 3px
top: 100%
left: 0
background: #347cdb
transition: transform 0.5s
transform: scaleX(0)
transform-origin: right
}
ul li a:hover {
color: #585858
text-shadow: 0 0 10px #ccc
}
ul li a:hover::after {
transform: scaleX(1)
transform-origin: left
}
</style>
</head>
<body>
<ul>
<li><a href="#">home</a></li>
<li><a href="#">archives</a></li>
<li><a href="#">tags</a></li>
<li><a href="#">categories</a></li>
<li><a href="#">about</a></li>
</ul>
</body>
</html>
以上需要的文件及图片
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
/* 公用 */
body{ margin:0overflow:hidden}
img{ display:block}
span{ display:block}
a{ text-decoration:nonedisplay:blockcolor:#000}
p,h1,h2,h3,h4{ margin:0font-weight: normalfont-size:12px}
ul{ margin:0padding:0}
input{ margin:0padding:0outline:noneborder:none}
body{ font-family:"微软雅黑"font-size:14pxbackground-color:#f2f2f2}
body h2,h3,h4{ color:#000}
ul{ margin:0padding:0}
li{ list-style:none}
.clearfix{ clear:both}
/*内容*/
.nav_box>li{ position:relativefloat:leftwidth:100pxtext-align:centermargin-top:10pxheight:30pxcursor:default}
.nav_box>li>h2{ border-right:1px solid #cccheight:16pxmargin-top:7pxfont-weight:boldwidth:90pxdisplay:blocktext-align:leftpadding-left:16pxbox-sizing:border-box}
.nav_box>li>img{ position:absolutetop:12pxright:18px}
.subnav_box{ position:absolutetop:30pxright:0pxwidth:300pxheight:400pxbackground-color:#fffbox-sizing:border-boxpadding:20px}
.subnav_box ul{ float:leftmargin-right:20px}
.subnav_box ul>li{ line-height:24px}
.nav_box>li:hover{ background-color:#fff}
.nav_box li:hover .subnav_box{ display:block}
</style>
<script src="jquery.js"></script>
<script>
$(function(){
$(".nav_box>li").mouseenter( function(){
$(".nav_box>li").children(".subnav_box").hide()
$(this).children(".subnav_box").show()
$(this).children("img").attr("src","img/arrow_bottom_gary.png")
}).mouseleave( function(){
$(".nav_box>li").children(".subnav_box").hide()
$(this).children("img").attr("src","img/arrow_top_gary.png")
}
)
})
</script>
</head>
<body>
<ul class="nav_box">
<li><h2>手机京东</h2>
</li>
<li><h2>客户服务</h2><img src="img/arrow_top_gary.png">
<div class="subnav_box" style=" left:-100pxdisplay:none">
<ul>
<li><b>特色栏目</b></li>
<li><a href="#">视频购物</a></li>
<li><a href="#">京东社区</a></li>
<li><a href="#">视频购物</a></li>
<li><a href="#">京东社区</a></li>
<li><a href="#">视频购物</a></li>
<li><a href="#">京东社区</a></li>
</ul>
<ul>
<li><b>旗下网站</b></li>
<li><a href="#">视频购物</a></li>
<li><a href="#">京东社区</a></li>
<li><a href="#">视频购物</a></li>
</ul>
</div>
</li>
<li><h2 style="border-width:0">网站导航</h2><img src="img/arrow_top_gary.png">
<div class="subnav_box" style="display:none">
<ul>
<li><b>特色栏目</b></li>
<li><a href="#">视频购物</a></li>
<li><a href="#">京东社区</a></li>
<li><a href="#">视频购物</a></li>
<li><a href="#">京东社区</a></li>
<li><a href="#">视频购物</a></li>
<li><a href="#">京东社区</a></li>
</ul>
<ul>
<li><b>企业服务</b></li>
<li><a href="#">视频购物</a></li>
<li><a href="#">京东社区</a></li>
</ul>
<ul>
<li><b>旗下网站</b></li>
<li><a href="#">视频购物</a></li>
<li><a href="#">京东社区</a></li>
<li><a href="#">视频购物</a></li>
</ul>
</div>
</li>
</ul>
</body>
</html>