html鼠标悬停下划线消失,CSS3 2个实用的鼠标悬停文本下划线动画效果

本文介绍了一种使用 CSS 实现的链接效果,通过伪元素 ::before 和 ::after 来创建平滑过渡的悬停效果。这些效果包括颜色变化及背景色扩展,适用于现代网页设计。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CSS

语言:

CSSSCSS

确定

@import 'https://fonts.googleapis.com/css?family=Lora:400,700';

* {

box-sizing: border-box;

}

html,

body {

font-family: 'Lora', serif;

width: 100%;

height: 100%;

display: -webkit-box;

display: -webkit-flex;

display: -ms-flexbox;

display: flex;

-webkit-box-align: center;

-webkit-align-items: center;

-ms-flex-align: center;

align-items: center;

-webkit-box-pack: center;

-webkit-justify-content: center;

-ms-flex-pack: center;

justify-content: center;

}

body {

border: 8px solid #00B388;

margin: 0;

}

a {

cursor: pointer;

}

strong {

margin-top: 16px;

display: block;

font-weight: 700;

}

p {

padding: 24px;

max-width: 760px;

font-size: 22px;

font-weight: 300;

line-height: 1.9;

}

.link-1 {

position: relative;

text-decoration: none;

display: inline-block;

color: black;

padding: 0 1px;

-webkit-transition: color ease 0.3s;

transition: color ease 0.3s;

}

.link-1::after {

content: '';

position: absolute;

z-index: -1;

width: 100%;

height: 5%;

left: 0;

bottom: 0;

background-color: #00B388;

-webkit-transition: all ease 0.3s;

transition: all ease 0.3s;

}

.link-1:hover {

color: white;

}

.link-1:hover::after {

height: 100%;

}

.link-2 {

position: relative;

text-decoration: none;

display: inline-block;

color: black;

padding: 0 1px;

-webkit-transition: color ease 0.3s;

transition: color ease 0.3s;

}

.link-2::before,

.link-2::after {

content: '';

position: absolute;

background-color: #00B388;

z-index: -1;

height: 5%;

}

.link-2::before {

width: 0%;

left: 0;

bottom: 0;

-webkit-transition: width ease 0.4s;

transition: width ease 0.4s;

}

.link-2::after {

width: 100%;

left: 0;

bottom: 0;

-webkit-transition: all ease 0.6s;

transition: all ease 0.6s;

}

.link-2:hover::before {

width: 100%;

}

.link-2:hover::after {

left: 100%;

width: 0%;

-webkit-transition: all ease 0.2s;

transition: all ease 0.2s;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值