使用 CSS 為選擇項設定樣式


要設定 <select> 中選項的樣式,你可以嘗試執行以下程式碼:

示例

動態演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         select {
            width: 100%;
            padding: 10px 15px;
            border: 1px dashed blue;
            border-radius: 4px;
            background-color: orange;
         }
      </style>
   </head>
   <body>
      <p>Learn,</p>
      <form>
         <select id = "country" name = "country">
            <option value = "java">Java</option>
            <option value = "ruby">Ruby</option>
            <option value = "oracle">Oracle</option>
            <option value = "tableau">Tableau</option>
         </select>
      </form>
   </body>
</html>

更新於: 23-Jun-2020

2K+ 檢視

開啟你的 職業生涯

完成課程獲取認證

開始學習
廣告
© . All rights reserved.