【问题标题】:Put a button inside the <a></a> tag using pug.js使用 pug.js 在 <a></a> 标记内放置一个按钮
【发布时间】:2019-08-09 18:15:05
【问题描述】:

这是我的预期结果:

<a>
    <button class="btn btn-tomato mx-auto" type="button" style="width:50%; white-space: normal; opacity:0.8;">Button text</button>  
</a>

所以我这样写了我的哈巴狗:

a
    button.btn.btn-tomato.mx-auto(type='button', style='width:50%; white-space: normal; opacity:0.8')

但是,结果是这样的:

<a></a>
<button class="btn btn-tomato mx-auto" type="button" style="width:50%; white-space: normal; opacity:0.8;">Button text</button>

&lt;button&gt; 不在&lt;a&gt; 中。你能告诉我如何解决这个问题吗?谢谢。

【问题讨论】:

    标签: html node.js pug


    【解决方案1】:

    HTML 禁止按钮出现在锚点内。

    • 如果您需要链接,请使用&lt;a&gt;

    • 如果您想提交表单,请使用&lt;button&gt;

    • 如果您想要触发 JavaScript 并且无法编写 Unobtrusive JS,请使用 &lt;button type="button"&gt;

    然后应用 CSS 让它看起来像你想要的那样。

    【讨论】:

      猜你喜欢
      • 2022-01-23
      • 2021-10-19
      • 2018-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多