您好,登錄后才能下訂單哦!
本文小編為大家詳細(xì)介紹“怎么用css實現(xiàn)button按鈕的點(diǎn)擊效果”,內(nèi)容詳細(xì),步驟清晰,細(xì)節(jié)處理妥當(dāng),希望這篇“怎么用css實現(xiàn)button按鈕的點(diǎn)擊效果”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來學(xué)習(xí)新知識吧。
1.首先創(chuàng)建一個html文件。
2.在html文件中添加html代碼架構(gòu)。
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>按鈕點(diǎn)擊效果</title> </head> <body> </body> </html>
3.然后在html代碼架構(gòu)中的body標(biāo)簽里面使用button標(biāo)簽設(shè)計一個按鈕。
<button class="primary-btn">主要按鈕</button>
4.在html架構(gòu)中的html標(biāo)簽里面添加style標(biāo)簽并寫入css樣式代碼來實現(xiàn)按鈕點(diǎn)擊效果。
<style> .primary-btn { font-size: 14px; color: #fff; height: 44px; padding: 0 15px; background-color: #07c160; border: 1px solid #07c160; line-height: 1.2; text-align: center; border-radius: 2px; cursor: pointer; transition: opacity 0.2s; outline: none; position: relative; } .primary-btn::before { position: absolute; top: 50%; left: 50%; width: 100%; height: 100%; background-color: #000; border: inherit; border-color: #000; border-radius: inherit; transform: translate(-50%, -50%); opacity: 0; content: ' '; } .primary-btn:active::before { opacity: 0.1; } </style>
5.最后可通過瀏覽器方式閱讀html文件查看設(shè)計效果。
完整示例代碼如下:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>按鈕點(diǎn)擊效果</title> <style> .primary-btn { font-size: 14px; color: #fff; height: 44px; padding: 0 15px; background-color: #07c160; border: 1px solid #07c160; line-height: 1.2; text-align: center; border-radius: 2px; cursor: pointer; transition: opacity 0.2s; outline: none; position: relative; } .primary-btn::before { position: absolute; top: 50%; left: 50%; width: 100%; height: 100%; background-color: #000; border: inherit; border-color: #000; border-radius: inherit; transform: translate(-50%, -50%); opacity: 0; content: ' '; } .primary-btn:active::before { opacity: 0.1; } </style> </head> <body> <button class="primary-btn">主要按鈕</button> </body> </html>
讀到這里,這篇“怎么用css實現(xiàn)button按鈕的點(diǎn)擊效果”文章已經(jīng)介紹完畢,想要掌握這篇文章的知識點(diǎn)還需要大家自己動手實踐使用過才能領(lǐng)會,如果想了解更多相關(guān)內(nèi)容的文章,歡迎關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。