HTML5+CSS3小實(shí)例:自帶射燈的浮雕按鈕

實(shí)例:自帶射燈的浮雕按鈕
技術(shù)棧:HTML+CSS
效果:

源碼:
【html】

<!DOCTYPE html>
<html>
 
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
 
    <title>自帶射燈的浮雕按鈕</title>
    <link rel="stylesheet" href="../css/89.css">
</head>
 
<body>
    <button>求點(diǎn)贊</button>
    <button>求關(guān)注</button>
    <button>求收藏</button>
    <button>求轉(zhuǎn)發(fā)</button>
</body>
 
</html>

【css】

*{
    /* 初始化 */
    margin: 0;
    padding: 0;
}
body{
    /* 100%窗口高度 */
    height: 100vh;
    /* 彈性布局 水平+垂直居中 */
    display: flex;
    justify-content: center;
    align-items: center;
    /* 垂直排列 */
    flex-direction: column;
    background-color: #333;
}
button{
    margin: 10px;
    width: 280px;
    height: 90px;
    font-size: 35px;
    font-weight: bold;
    background: transparent;
    border: 1px solid transparent;
    /* 相對(duì)定位 */
    position: relative;
    /* 設(shè)置內(nèi)陰影 */
    box-shadow: inset 1px 1px 2px #000,inset -1px -1px 2px #808080;
    color: #333;
    /* 文本陰影 */
    text-shadow: 1px 1px 0 #808080;
    overflow: hidden;
    /* 設(shè)置過渡 */
    transition: 0.3s linear 0.15s;
}
/* 分別為各個(gè)按鈕設(shè)置自定義屬性--c(顏色值) */
button:nth-child(1){
    --c:#ff4757;
}
button:nth-child(2){
    --c:#ffa502;
}
button:nth-child(3){
    --c:#2ed573;
}
button:nth-child(4){
    --c:#1e90ff;
}
/* 射燈 */
button::before{
    content: "";
    /* 絕對(duì)定位 */
    position: absolute;
    width: 100px;
    height: 8px;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 0 0 50% 50%;
    /* 模糊濾鏡 */
    filter: blur(5px);
    /* 設(shè)置過渡 */
    transition: 0.3s;
}
button:hover::before{
    /* 通過var函數(shù)調(diào)用自定義屬性--c,設(shè)置顏色 */
    background: var(--c);
    box-shadow: 0 0 10px var(--c),
    0 0 20px var(--c),
    0 0 30px var(--c),
    0 0 40px var(--c),
    0 0 50px var(--c);
}
button:hover{
    color: #fff;
    text-shadow: 0 0 10px var(--c),
    0 5px 5px #000;
    box-shadow: inset 1px 1px 2px #000,
    inset -1px -1px 2px var(--c);
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容