用 CSS 設定獲取焦點的元素的樣式
為了選擇有焦點的元素,使用:focus 選擇器。你可以嘗試執行以下程式碼來實現:focus 選擇器 −
示例
<!DOCTYPE html> <html> <head> <style> input:focus { background-color: green; } </style> </head> <body> <form action = ""> Subject <input type = "text" name = "subject"><br> Student: <input type = "text" name = "student"><br> Age: <input type = "number" name" = age><br> <input type = "submit" value="Submit"> </form> </body> </html>
廣告