Html 按钮和表单之间没有换行符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9117209/
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
no line break between button and form
提问by Roland
How do I get a button and a form element in the same line without a linebreak happening? thank you very much!
如何在同一行中获取按钮和表单元素而不会发生换行?非常感谢!
<button>ask question</button>
<form action="/search" method="get">
<input type="text" name="q" value="{SearchQuery}"/>
<input type="submit" value="Search"/>
</form>
回答by p.campbell
Use this CSS style: style="display: inline;"
on your form.
使用此 CSS 样式:style="display: inline;"
在您的表单上。
<form action="/search" method="get" style="display: inline;">
Here's a demo on JSBin.
回答by nolt2232
You could make the button a float:
您可以使按钮浮动:
<button style="float: left;">ask question</button>
回答by bzx
both <button>
and <form>
are block level elements. you'd need to make them inline with CSS display: inline
. not sure if that's what you mean. also it depends on your broader HTML.
两个<button>
和<form>
是块级元素。您需要使它们与 CSS 内联display: inline
。不知道这是否是你的意思。它还取决于您更广泛的 HTML。
回答by IanGilham
Input fields are block-level elements. You can change the display rules in CSS:
输入字段是块级元素。您可以更改 CSS 中的显示规则:
input { display: inline; }
回答by iblazevic
You can float: left both the button and the form
您可以浮动:同时离开按钮和表单