`min-width`不能用于`input [type ="button"]`元素吗?

Yar*_*rin 9 html css forms input button

有人看到为什么这不起作用的原因?(与之合作width,但不是min-width)

input[type="button"] {
    min-width: 100px;
}
Run Code Online (Sandbox Code Playgroud)

编辑:澄清

  • "按钮"选择器可以使用width,而不是min-width
  • min-width 与其他元素一起使用,而不是"按钮"选择器
  • 这是在chrome/safari上.不是IE问题.

Jos*_*osh 5

我也刚遇到这个问题。min-width确实有效,但可能无法为您提供预期的结果,或者由于按钮的默认box-sizing值为border-box. 尝试box-sizing: content-box在按钮上设置。


Lat*_*tox 0

min-width在旧版本的 Internet Explorer 中不受支持和/或存在错误。

您可以在此处查看兼容性表

min-width这是在元素上使用的示例,为其form设置属性总是明智的。width

<html>
<head>
<title>TAG index</title>

<style type="text/css">

.example {
  width: 100%;
  max-width: 600px;
  min-width: 500px;
}

textarea {
  height: 10em;
}

</style>

</head>

<body>

<p>minimum width:500px - maximum width:600px</p>

<form method="POST" action="example.cgi">

  <p><input type="text" name="item1" class="example"></p>

  <p><select name="item2" class="example">
    <option value="select1">Select1</option>
    <option value="select2">Select2</option>
    <option value="select3">Select3</option>
  </select></p>

  <p><textarea name="item3" cols="50" rows="10" class="example"></textarea></p>

</form>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)