简体   繁体   English

如何在html按钮中添加两行(一个为条件行)?

[英]How can I add two lines (one conditional) inside an html button?

I'm trying to add two lines inside an HTML button, but can't seem to find anywhere what elements are allowed - I know divs, paragraphs, and breaks aren't. 我正在尝试在HTML按钮中添加两行,但似乎找不到任何允许使用什么元素的地方-我知道div,段落和中断是不允许的。

What I have so far is this: 我到目前为止所拥有的是:

<button>
  Option 1
  <span ng-if="{{option2Allowed}}>Option2</span>
</button>

I want to be able to make Option 2 be on a different line than Option 1. So, if option2Allowed defaults to 'true', I have something like the following: 我希望能够使选项2与选项1不在同一行。因此,如果option2Allowed默认为'true',那么我将具有以下内容:

Option 1 选项1
Option 2 选项2

How would I do this? 我该怎么做?

Wrap both lines in a span tag, and set the display mode for the spans to block . 包裹在一个两行span标签,并设置显示模式spansblock Your second line span can still have the conditional statement. 您的第二行跨度仍然可以有条件语句。

Example: https://jsfiddle.net/8k27g984/ 示例: https//jsfiddle.net/8k27g984/

CSS tables perhaps might suit? CSS表也许适合?

 button { display: table; margin-bottom: 1em; } button span { display: table-row; } 
 <button> <span>Option1</span> <span>Option2</span> </button> <button> <span>Option1</span> </button> 

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

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