html css响应式发光按钮

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>响应式发光按钮</title>
        <link rel="stylesheet" href="indexCss.css">
    </head>
    <body>
        <div class="con">
            <a href="#">
                <span>button</span>
            </a>
        </div>
    </body>
</html>
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;

}

/* body{
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #0e1538;
} */
.con{
    display: flex;
    position: relative;
    left: 300px;
    top: 300px;
    /* width: 200px;
    height: 100px; */
    flex-direction: column;
    background-color: #0e1;
}
.con a{
    position: absolute;
    width: 200px;
    height: 100px;
    display: inline-block;
}

.con a:before,
.con a:after{
    content: '';
    position: absolute;
    inset: 0;
    transition: 0.5s;
    background: #f00;
}
.con a:hover:before{
    inset: -3px;
}
.con a:hover:after{
    inset: -3px;
    filter: blur(5px);/*之前颜色延伸的阴影大小*/
}

.con a span{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: inline-block;
    background: #0e1538;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
    text-transform: uppercase;/*将数字转换成大写*/
    letter-spacing: 2px;/*调整字与字之间的距离*/
    color: #fff;
}

这个css首先是让按键呈现出移动到光标上显示红色背景的动态效果
主要有

设计背景的颜色(红色)必须是在button字的元素上面进行before和after操作
tranition:是动画效果时间,但没有insert:0是没有动画效果的
.con a:hover:before里的inset:-3px改变了效果,且必须负数

其实这就完成了,想要完成 炫酷的效果就要用到linear-gradient()就行了:

.con a:nth-child(1):before,
.con a:nth-child(1):after{
    background: linear-gradient(45deg,#00ccff,#0e1538,#0e1538,#d400d4);
}

效果为:
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

结城明日奈是我老婆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值