简体   繁体   English

HTML:我可以在多行显示按钮文字吗?

[英]HTML: can I display button text in multiple lines?

I have a button with long text like "Click here to start playing". 我有一个长文本按钮,如“点击此处开始播放”。 I want to control the width and display the text in multiple lines. 我想控制宽度并以多行显示文本。 Is it possible in html/css? 是否可以在html / css中?

Yes, you can have it on multiple lines using the white-space css property :) 是的,你可以使用white-space css属性在多行上拥有它:)

 input[type="submit"] { white-space: normal; width: 100px; } 
 <input type="submit" value="Some long text that won't fit." /> 

add this to your element 将此添加到您的元素

 white-space: normal;
 width: 100px;

Two options: 两种选择:

<button>multiline<br/>button<br/>text</button>

or 要么

 <input type="button" value="Carriage&#13;&#10;return&#13;&#10;separators" style="text-align:center;">

这个CSS可能适用于<input type="button" ..

white-space: normal

Yes it is, and you can also use it like this 是的,你也可以像这样使用它

<button>Click here to<br/> start playing</button>

if you want to make the break yourself. 如果你想自己休息一下

one other way to improve and style the multi-line text is 另一种改进和设计多行文本的方法是

 <button>Click here to<br/> 
     <span style="color:red;">start playing</span>

   </button>

You can break a text using an entity in between the value. 您可以使用值之间的实体来中断文本。 See the entity in example below: 请参阅以下示例中的实体:

<input style="width:100px;" type="button" value="Click here &#x00A; to &#x00A; start playing">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM