如何让input宽度自适应?

mingfish2 mingfish2 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
如何让input宽度自适应?

demo:http://linjuming.zy1668.com/my_question/input_width/input_width.htm
对于input高度和宽度css一直都觉得恶心,到底怎么控制?


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>input width</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<style type="text/css">
.box{width:300px;height:200px;background-color:tan;padding-top:50px;}
.box div{height:30px;background-color:green;padding-top:5px;}
.box div input{width:100%;padding:0 5px;}
</style>
<div class="box pdr20">
<div>
<input type="text" name="" />
</div>
</div>
</body>
</html>



...全文
评论 6
收藏 已收藏
分享
返回顶部
mingfish2
CSS 61,117 成员 60,701 内容