简体   繁体   English

Bootstrap4,btn和btn-primary类不适用于链接(“ a”标签)

[英]Bootstrap4, btn and btn-primary classes don't work for link (“a” tag)

I am using Bootstrap version 4.1, there are no custom styles in my page. 我正在使用Bootstrap 4.1版,页面中没有自定义样式。 Here is the code for displaying buttons: 这是显示按钮的代码:

<div class="btn-group" role="group" aria-label="">
<a class="btn btn-primary" type="button" href="{% url 'website_admin_create_user' %}">
    <i class="fas fa-user-plus"></i>&nbsp;{% trans 'Add user' %}
</a>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#listFilter" aria-expanded="false" aria-controls="listFilter">
    <i class="fas fa-filter"></i>&nbsp;{% trans 'Filters' %}
</button>

The problem is that, style for a tag is not working, despite I can see it in browser inspector. 问题是,风格a标签不能正常工作,尽管我可以在浏览器中检查看看吧。 What might cause such behavior? 什么可能导致这种行为?

boostrap 4链接样式

检查器标签

您正在<a>标记上使用按钮css类,只需将其切换为<button>无需<a>

Change your line to 将行更改为

<a href="{% url 'website_admin_create_user' %}">
   <button  class="btn btn-primary">
      <i class="fas fa-user-plus"></i>&nbsp;{% trans 'Add user' %}
   </button>
</a>

instead of 代替

<a class="btn btn-primary" type="button" href="{% url 'website_admin_create_user' %}">
     <i class="fas fa-user-plus"></i>&nbsp;{% trans 'Add user' %}
</a>

发现了问题: type="button"造成了此混乱,只需将其删除,一切都会按预期进行。

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

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