W3C验证器说:"此时元素输入不允许属性大小."
<input type="file" name="foo" size="40" />
Run Code Online (Sandbox Code Playgroud)
在HTML5中指定文件输入宽度的正确方法是什么?
sil*_*uri 10
在输入字段中使用style属性,这允许您使用css.
<input type="file" name="foo" style="width: 40px" />
或者使用单独的css:
input[name="foo"] {
width: 40px;
}
Run Code Online (Sandbox Code Playgroud)
在您的 css 文件中,指定宽度如下:
input[type=file] { width: 300px; border: 2px solid red; }
Run Code Online (Sandbox Code Playgroud)