樣式具有“readonly”屬性的元素帶有 CSS


要選擇只讀的元素,請使用 CSS :read-only 選擇器。

示例

你可以嘗試執行以下程式碼來實現 :read-only 選擇器

即時演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         input:read-only {
            background-color: blue;
            color: white;
         }
      </style>
   </head>
   <body>
      <form>
         Subject: <input type = "text" name = "subject" value = "Maths"><br>
         Student: <input type = "text" name = "student" readonly value = "Amit"><br>
      </form>
   </body>
</html>

更新日期: 2020 年 7 月 1 日

2K+ 檢視次數

開啟你的 職業生涯

完成課程獲得認證

開始使用
廣告