1. 程式人生 > 實用技巧 >通過CSS 來改善Button 外觀

通過CSS 來改善Button 外觀

HTML 文件中 <button> 標籤每出現一次,javascript中Button 物件就會被建立。

Button 物件的屬性

屬性描述
accessKey 設定或返回訪問某個按鈕的快捷鍵。
disabled 設定或返回是否禁用按鈕。
form 返回對包含按鈕的表單的引用。
id 設定或返回按鈕的 id。
name 設定或返回按鈕的名稱。
tabIndex 設定或返回按鈕的 Tab 鍵控制次序。
type 返回按鈕的表單型別。
value 設定或返回顯示在按鈕上的文字。

例項:通過CSS 來改善按鈕的外觀:

<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8">
  <title>HTML CSS Exercise CSS3 button</title>
   <style type="text/css">
     button {  
        width: 200px;  
        padding:8px;  
        background-color: #428bca;  
        border-color: #357ebd;  
        color: #fff;  
        -moz-border-radius: 10px;  
        -webkit-border-radius: 10px;  
        border-radius: 10px; /* future proofing */  
        -khtml-border-radius: 10px; /* for old Konqueror browsers */  
        text-align: center;  
        vertical-align: middle;  
        border: 1px solid transparent;  
        font-weight: 900;  
        font-size:125%  
      }  
   </style>
  </head>
 <body>
  <button>
    Subscribe Now
   </button>
 </body>
</html>