优雅美感按钮的样式(练习/仿写)

pretty-button

 

HTML结构:

<body>
    <button class="pretty-button">Pretty Button</button>
</body>

 

CSS样式:

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #e8e8e8; 
}

.pretty-button {
    color: #282828;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 20px;
    padding: 1em 2em;
    border: none;
    border-radius: 0.5em;
    background-color: #e8e8e8;
    box-shadow: 
        8px 8px 16px rgba(163, 163, 163, .5), 
        -8px -8px 16px rgba(255, 255, 255, .9);
    outline: none;
    transition: all 240ms ease-in-out;
    cursor: pointer;
}

/* 鼠标悬停状态 */
.pretty-button:hover {
    box-shadow: 
        9px 9px 18px rgba(163, 163, 163, .6), 
        -9px -9px 18px rgba(255, 255, 255, 1);
}

/* 鼠标按下状态(呈现凹陷感) */
.pretty-button:active {
    box-shadow: 
        inset 4px 4px 8px rgba(163, 163, 163, .5),
        inset -4px -4px 8px rgba(255, 255, 255, .9);
}

 

仿写源链接:See Here

posted @ 2026-11-09 22:19  樊顺  阅读(16)  评论(0)    收藏  举报