使用 CSS 設定按鈕寬度


要設定按鈕寬度,請使用 CSS width 屬性。

示例

你可以嘗試執行以下程式碼來設定按鈕的寬度 −

線上演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         .btn {
            background-color: yellow;
            color: black;
            width: 120px;
            text-align: center;
            font-size: 15px;
            padding: 20px;
            border-radius: 15px;
            border: 3px dashed blue;
         }
      </style>
   </head>
   <body>
      <h2>Result</h2>
      <p>Click below for result:</p>
      <button class = "btn">Result</button>
   </body>
</html>

更新於: 03-Jul-2020

5K+ 瀏覽

開啟你的 職業

透過完成課程獲得認證

開始
廣告
© . All rights reserved.