html - Bootstrap 按钮移到包含 div 的右侧

标签 html css bootstrap-4

我有一个非常简单的 Bootstrap 页面,其中有一个包含一列按钮的 div。没有明显的原因,按钮略微向右移动:

enter image description here

enter image description here

enter image description here

包含的 div(如上突出显示)没有填充或边距:

enter image description here

并且按钮在两侧应用了相同的边距:

enter image description here

关联的 html:

<div class="cinema-list" style="max-width: 700px;" class="m-auto">
    <h2>Select Cinema</h2>

    <div class="form-group">
        <label for="cinemaSearchInput">Search</label>
        <input 
            type="text" 
            class="form-control" 
            id="cinemaSearchInput" 
            placeholder="Cinema name..."
            [(ngModel)]="searchString"
            >
    </div>

    <div *ngIf="cinemaList != null">

        <button 
            *ngFor="let cinema of cinemaList" 
            type="button"
            class="btn btn-primary cinema-button m-1 w-100"
            (click)="selectCinema(cinema)"
            >
            <span>{{cinema.name}}</span>
            <i 
                *ngIf="isFavoriteCinema(cinema)"
                class="fa fa-heart pl-1 heart" 
                aria-hidden="true"></i>
        </button>

    </div>

    <div 
        *ngIf="cinemaList == null" 
        class="d-flex align-items-center pt-2">
            <span class="spinner-border text-primary mr-2"></span>
            <span>Loading...</span>
    </div>
</div>

和 scss:

.cinema-list{
    .cinema-button{
        display: block;
    }

    .cinema:hover{
        background-color: $primary;
    }
}

我看不出按钮移动的任何原因。这是 Bootstrap 的错误吗?

这是 boostrap 4.3.1

谢谢

最佳答案

这是因为你在按钮中添加了class m-1。请从中删除该类。

替换

 class="btn btn-primary cinema-button m-1 w-100"

 class="btn btn-primary cinema-button w-100"

希望对您有所帮助。

关于html - Bootstrap 按钮移到包含 div 的右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58497913/

相关文章:

python - 如何删除 BeautifulSoup 中所有不同的脚本标签?

html - 桌面优先尝试使用媒体查询

javascript - 在单击 Bootstrap 选项卡之前,Jquery 无法隐藏和显示 div

css - Bootstrap 模式弹出窗口使屏幕变暗,但屏幕的少数部分仍显示在同一级别并且不会变暗

html - 如何在 Angular4 中的两行产品之间留出空间

javascript - 在 Blogger 中按标签导航下一篇和上一篇文章

javascript - 为什么下面的代码生成 4 个元素而不是 2 个?

html - 在 Bootstrap 中居中文本

javascript - 嵌套的 HTML 列表项可以强制左对齐吗?

html - 带有移动导航栏按钮的垂直对齐播放按钮