css中可以使用width和height属性来设置文本框的宽和高,只需要给文本框元素(input或textarea)添加“width:值;”和“height:值;”样式即可。width属性可设置元素的宽度,height属性以设置元素的高度。
本教程操作环境:Windows7系统、css1&&html5版本、Dell G3电脑。
教程推荐:css视频教程
css设置文本框宽度和高度的方法
给文本框元素(、
立即学习“前端免费学习笔记(深入)”;
width属性设置元素的宽度,height属性设置元素的高度。
注意: width属性和height属性不包括填充,边框,或页边距!
示例:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style type="text/css"> .input{ width: 200px; height: 100px; } .textarea{ idth: 200px; height: 100px; } </style> </head> <body> <input type="text" placeholder="默认单行文本框" /> <input type="text" class="input" placeholder="设置宽度200px,高度100px" /><br /><br /> <textarea placeholder="默认多行文本框"></textarea> <textarea class="textarea" placeholder="设置宽度200px,高度100px"></textarea> </body> </html>
效果图:
更多编程相关知识,请访问:编程课程!!
以上就是css怎么设置文本框的宽和高的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号