Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为HTML按钮设置适当的宽度_Html - Fatal编程技术网

为HTML按钮设置适当的宽度

为HTML按钮设置适当的宽度,html,Html,当我使用HTML创建表单时,按钮的大小不同(作为输入值的大小) 可以使用CSS为HTML按钮设置适当的宽度 <form> <input type="button" value="input"><br> <input type="button" value="ok"> </form> 您有几个选择 1) 您可以使用内联样式(不是最佳实践) 选项1 参见示例 HTML: 选项2: 见示例: HTML: 没有其他方法可以设置html

当我使用HTML创建表单时,按钮的大小不同(作为输入值的大小)

可以使用
CSS
HTML
按钮设置适当的宽度

<form>
<input type="button" value="input"><br>
<input type="button" value="ok">
</form>



您有几个选择

1) 您可以使用内联样式(不是最佳实践)


选项1

参见示例

HTML:

选项2:

见示例:

HTML:




没有其他方法可以设置html元素的样式。但是有一种方法可以在html中为每个按钮设置标签样式。加上

   <style>
    input[type="button"] {
        width: 13px;
    }
</style>

输入[type=“button”]{
宽度:13px;
}

这是一种选择,但根本不是一种好的做法。

嗨,你能告诉我们你做了什么吗?也没有css?为什么呢
没有CSS?否,输入元素的width属性仅在type=image时根据w3s工作。
 button {
    width: 50px;
    height: 20px;
 }
    <form>
<input type="button" value="input" id='button1'><br>
<input type="button" value="ok" id ='button2'>
</form>
     #button1 {
        width:400px;
     }

    #button2{
        width:100px;
    }
<form>
<input type="button" value="input" style="width:400px"><br>
<input type="button" value="ok" style="width:100px"'>
</form>
   <style>
    input[type="button"] {
        width: 13px;
    }
</style>