使用 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.