文章数量
28
访客量
2925
访问量
5820

css特效之炫酷的发光按钮

阅读量:449
更新时间:2023-02-26 12:23:29

效果预览:效果预览
源码下载:关注公众号【RMRF】,回复【css7】可获取源码

一、HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>按钮</title>
    <link rel="stylesheet" href="./css/index.css">
</head>
<body>
    <button>
        <span>Hellow World</span>
        <div class="top"></div>
        <div class="bottom"></div>
        <div class="left"></div>
        <div class="right"></div>
    </button>
</body>
</html>

二、CSS样式

body {
    display: flex;
    justify-content: center;
    background-color: #202020;
}

button {
    position: relative;
    margin-top: 300px;
    padding: 20px 60px;
    cursor: pointer;
    transition: 0.5s all;
    background-color: #202020;
}

button span {
    color: #646464;
    font-size: 20px;
}

button:hover {
    box-shadow: inset 0px 0px 25px #ff7700;
}

button:active {
    margin-top: 305px;
    transition: 0.2s all;
    box-shadow: inset 0px 0px 25px #ffaf6a;
}


button div {
    transition: 0.5s all;
    position: absolute;
    background-color: #ff7700;
    box-shadow: 0 0 15px #ff7700, 0 0 30px #ff7700, 0 0 50px #ff7700;
}

button .top {
    width: 15px;
    height: 2px;
    top: 0;
    left: 0;
}

button .bottom {
    width: 15px;
    height: 2px;
    bottom: 0;
    right: 0;
}

button .left {
    width: 2px;
    height: 15px;
    top: 0;
    left: 0;
}

button .right {
    width: 2px;
    height: 15px;
    right: 0;
    bottom: 0;
}

button:hover .top,
button:hover .bottom {
    width: 100%;
}

button:hover .left,
button:hover .right {
    height: 100%;
}