在css中,可以利用“:active”選擇器和border屬性實(shí)現(xiàn)按鈕點(diǎn)擊時(shí)修改邊框效果,語(yǔ)法為“按鈕元素:active{border:邊框粗細(xì)值 solid 顏色值}”。
本教程操作環(huán)境:windows10系統(tǒng)、css3&&html5版、dell g3電腦。
css怎樣在按鈕點(diǎn)擊時(shí)修改邊框
在css中,可以用:active選擇器和border屬性實(shí)現(xiàn)按鈕點(diǎn)擊時(shí)修改邊框。
:active選擇器用于選擇元素被點(diǎn)擊時(shí),并設(shè)置樣式,border屬性用于設(shè)置元素的邊框樣式。
示例如下:
<!doctype html><html lang=\”en\”><head> <meta charset=\”utf-8\”> <meta name=\”viewport\” content=\”width=device-width, initial-scale=1.0\”> <meta http-equiv=\”x-ua-compatible\” content=\”ie=edge\”> <title>document</title> <style> button{ width:100px; height:50px; border-radius:25px; border:5px solid red; } button:active{ border:5px solid pink; } </style></head><body> <button>按鈕</button></body></html>
輸出結(jié)果:
(學(xué)習(xí)視頻分享:css視頻教程)