使用 HTML 和 CSS 实现按钮闪烁悬停效果

使用 HTML 和 CSS 实现按钮闪烁悬停效果

原视频连接
HTML:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <div>
        <button>Hover</button>
        <button>Hover</button>
    </div>
</body>

</html>

CSS:

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: black;
}

button {
    width: 210px;
    height: 50px;
    border: none;
    background-color: black;
    font-size: 23px;
    font-weight: 500px;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    outline: none;
    position: relative;
    transition: 0.6s;
    overflow: hidden;
}

button:first-child {
    color: skyblue;
    border: 1px solid skyblue;
    margin: 0 40px;
}

button:last-child {
    color: pink;
    border: 1px solid pink;
}

button::before,
button::after {
    position: absolute;
    content: '';
    left: 0;
    top: 0;
    background-color: rgba(255, 255, 255, 0.9);
    width: 100%;
    height: 100%;
    filter: blur(30px);
    //进行模糊度调整
    //filter文章末尾会说明
    opacity: 0.4;
    transition: 0.6s;
}

button::before {
    width: 60px;
    transform: translateX(-90px) skewX(-45deg);
    //skew文字末尾会说明
}

button::after {
    width: 40px;
    transform: translateX(-90px) skewX(-45deg);
}

button:hover::before,
button:hover::after {
    opacity: 0.6;
    transform: translateX(220px) skewX(-45deg);
}

button:hover {
    color: #fff;
}

button:hover:first-child {
    background-color: skyblue;
}

button:hover:last-child {
    background-color: pink;
}

filter滤镜详解

skew()详解

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值