Html 按钮宽度属性被忽略?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3186267/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:42:26  来源:igfitidea点击:

Button width property ignored?

htmlcssbutton

提问by CruftyCraft

Both Firefox and Safari don't seem to properly render a button specified with a certain width:

Firefox 和 Safari 似乎都没有正确呈现指定宽度的按钮:

<form>
<button>foo</button><br>
<button style="width=200px;height:200px">baz</button>
</form>

Button baz will render with specified height but default width. Same result in both Firefox and Safari.

按钮 baz 将以指定的高度呈现,但默认宽度。Firefox 和 Safari 中的结果相同。

Is this by design? How can I overcome this?

这是设计使然吗?我怎样才能克服这个问题?

回答by David says reinstate Monica

It's a syntax error:

这是一个语法错误:

<button style="width=200px;height:200px">baz</button>

Should be:

应该:

<button style="width:200px;height:200px">baz</button>