是否可以在两行中输出'submit'的值?

时间:2013-01-11 11:30:56

标签: html css submit-button

我有一个迷你表单,我需要将提交按钮的值的长文本分成两行,以便它适合父div的宽度。我尝试设置提交按钮的宽度,但这不起作用。

4 个答案:

答案 0 :(得分:5)

使用<button type="submit">代替<input type="submit">。这将允许您将按钮的内容提供为HTML而不是纯文本,允许您根据需要格式化按钮的内容。

最基本的解决方案是手动包含换行符:

<button type="submit">Foo<br/>Bar</button>

当然,您也可以使用更高级的CSS布局作为按钮内容。

<强> See it in action

答案 1 :(得分:2)

<span>

的第2行包裹您想要的文字
span{
    display:block
}

答案 2 :(得分:1)

<style>
.buttontext {
  width: 10px;
  white-space: wrap;
  display: block;
}
</style>
<button><span class=buttontext>Very long text Very long text
Very long text</span></button>

这会将文本包装在所需的行上。

答案 3 :(得分:1)

以下内容将文本包装在按钮上。请注意,我已指定宽度。

<input type="button" value="This is some text on the button" style="white-space:normal; width:100px;" />