源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <style> * { box-sizing: border-box; } input, textarea { width: 100%; } </style> </head> <body> <form action="action_page.asp"> 用戶名:<br> <input type="text" name="username" value="runoob"><br> 郵箱:<br> <input type="text" name="email" value="429240967@qq.com"><br> 評論:<br> <textarea name="message" rows="5" cols="30"> </textarea> <br><br> <input type="submit" value="提交"> </form> <p><strong>提示:</strong> 可以嘗試移除樣式中的 box-sizing 屬性,看看會發生什么。注意移除後部分瀏覽器 input, textarea, 和 submit 按鈕的寬度不一致。</p> </body> </html>
運行結果