CSS 表单 - 输入宽度不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11172081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CSS forms - input width not working
提问by jkcl
The following css:
以下css:
#contactform {
width: 400px;
height: 215px;
}
.webform {
}
.webform input .name {
width: 50px;
}
.webform input .email {
width: 70px;
}
.webform input .comments {
width: 200px;
}
when used in html as
当在 html 中使用时
<div id="contactform">
<div class="webform">
<input class="name" name="Name" type="text" id="senderName" placeholder="Enter your name here">
<input class="email" name="Email" type="text" id="senderEmail" placeholder="Enter a valid email adress here">
<br>
<input class="comments" name="Comments" type="text" id="senderComments" placeholder="Comments...">
</div>
</div>
produces all three input field of the same width (50px = that is, the width of the webform input
). I'm not sure what I'm doing wrong. Help?
生成所有三个相同宽度的输入字段(50px = 即 的宽度webform input
)。我不确定我做错了什么。帮助?
采纳答案by albert
your classes are on your input
s, not on child elements of the input
s. so change input .name
, etc., to input.name
or just .name
, repeat for all three. :)
您的课程在您的input
s 上,而不是在 s 的子元素上input
。因此input .name
,将 等更改为input.name
或只是.name
,对所有三个重复。:)