简体   繁体   English

CSS 向右移动按钮

[英]CSS moving button to right side

I am using bootstrap and angular material for the UI.我正在为 UI 使用引导程序和 angular 材料。 In one of my div.在我的一个 div 中。 I want to move my button to the right side but when I do apply class "float-right" it is going behind the other div.我想将我的按钮移到右侧,但是当我应用 class “float-right”时,它会在另一个 div 后面。 This is the image URL https://prnt.sc/y0xn90 Below is the code.这是图像 URL https://prnt.sc/y0xn90下面是代码。

<div class="card-body">
        <div class="tab-content">

          <!-- /.tab-pane -->
          <div class="active tab-pane" id="timeline">
            <div>
              <button mat-raised-button color="primary">Add Treatment</button>
            </div>
            <div>
              <ul class="timeline" *ngFor="let treatment of patientTreatments">
                <li class="timeline-item bg-white rounded ml-3 p-4 shadow">
                  <div class="timeline-arrow"></div>
                  <h2 class="h5 mb-0">{{treatment.title}}<span class="float-right" style="cursor: pointer;">
                      <mat-icon>edit</mat-icon>
                    </span></h2>
                  <span class="small text-gray"><i class="fa fa-clock-o mr-1"></i>{{treatment.treatmentDate}}</span>
                  <p class="text-small mt-2 font-weight-light">{{treatment.summary}}</p>
                  <div *ngFor="let files of treatment.treatmentFiles">
                    <img src="" alt="Treatment image">
                  </div>
                </li>
              </ul><!-- End -->
            </div>
            <!-- The timeline -->
          </div>
          <!-- /.tab-pane -->

          <div class="tab-pane" id="settings">
            111
          </div>
          <!-- /.tab-pane -->
        </div>
        <!-- /.tab-content -->
      </div><!-- /.card-body -->

you can use the display flex property with the width 100% and u can push left or right side with flex-end/flex-start您可以使用宽度为 100% 的 display flex 属性,您可以使用 flex-end/flex-start 向左或向右推

        <div style="width: 100%;display: flex;justify-content: flex-end;align-items: center;">
          <button mat-raised-button color="primary">Add Treatment</button>
        </div>

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

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