源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <style> .button { background-color: #4CAF50; /* Green */ border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; } .disabled { opacity: 0.6; cursor: not-allowed; } </style> </head> <body> <h2>禁用按鈕</h2> <p>我們可以使用 opacity 屬性為按鈕添加透明度 (看起來類似 "disabled" 屬性傚果)。</p> <button class="button">正常按鈕</button> <button class="button disabled">禁用按鈕</button> </body> </html>
運行結果