【问题标题】:Justify Angular Material Tab Body Content To Left将 Angular Material 选项卡正文内容向左对齐
【发布时间】:2019-11-30 00:26:28
【问题描述】:

我正在为 Angular 7 使用 Angular 材料。目前我遇到了如下图所示的问题。

有没有办法将内容选项卡向左推。例如像下面的图像。当我尝试向左推时,它隐藏在“方法”标题下方。

这是我的代码

HTML

<div class="method">
  <div>
    <h3 class="method-title">Mathod</h3>
    <hr class="line-method">
  </div>
  <mat-tab-group animationDuration="6ms">
    <mat-tab label="First">
      <ng-template mat-tab-label>
        <button type="button" class="btn  btn-white active">Personal Info</button>
      </ng-template>
      <div class="container tab-padd">
        <div class="row">
          <div class="col-md-6">
            <div class="form-group">
              <div class="sub-form">
                <label for="firstName">First Name</label>
                <input type="text" class="form-control shot" name="firstName"
                                                        required />
              </div>
              <div class="sub-form">
                <label class="right-inline" for="lastName">Last Name</label>
                <input value="" class="form-control shot" name="lastName"                                                        
                                                        required />
              </div>
            </div>
          </div>
        </div>
      </div>
    </mat-tab>
    <mat-tab label="Second">
      <ng-template mat-tab-label>
        <button type="button" class="btn btn-white active">Another Info</button>
      </ng-template>
      <div class="container tab-padd">
        <div class="row">
          <div class="col-md-6"> </div>
        </div>
      </div>
    </mat-tab>
  </mat-tab-group>

CSS

.method-title{
    padding: 12px 84px;
    width: max-content;
}

.line-title{
    margin-top: 4rem !important;
    /* margin-bottom: 3rem !important; */
    width: 22%;
    margin-left:-14px; 
    text-align:left;
}

.justify-content-left{
    padding-left: 85px;
}

.radio-group{
  display: flex;
  flex-direction: row;
  margin: 15px 0;
}

.justify-content-between{
    justify-content: space-between;
    display: flex;
}

.border{
    width: calc(100% - 46rem);
    text-align: left;
    margin-left: 4px;
}

#container {
    display: flex;
    justify-content: space-between; /* Can be changed in the live sample */
    width: 40%;
    padding-left: 1rem;
  }

  .space-bottom-2{
    padding-bottom: 2rem;
  }

  .custome-row{
    display: contents !important;
    line-height: 6px;
  }

  .method{
      display: flex;

  }

  .line-method{
    margin-top: -1.8rem !important;
    width: 78%;
    margin-left: -12px;
    text-align: left;
  }

  .mat-tab-label::ng-deep {
    width: 900rem !important;
}

  /* form specific formatting */
  .tab-padd{
    padding-top: 24px !important;
    column-span: all;
}
.form-group {
    display: flex;
    flex-direction: row;
  }

  .sub-form{
    flex-direction: column;
  }

  .form-group label {
    flex: none;
    display: block;
    width: 125px;
    font-weight: bold;
    font-size: 1em;
    white-space: nowrap;
  }
  .form-group label.left-inline {
    text-align: left;  
    padding-right: 8px;
    padding-left: 10px;
    width: auto;
  }

  .form-group .shot{
    width: 20rem
  }

  .form-group .long{
    width: 40rem
  }

如需演示,您可以前往Stackblitz

希望大家能帮忙。

提前致谢

【问题讨论】:

    标签: css angular typescript angular-material


    【解决方案1】:

    你可以给.mat-tab-body-wrapper提供负边距

    .mat-tab-body-wrapper{margin-left: -190px;}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-19
      • 1970-01-01
      • 2020-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-22
      • 2019-01-16
      相关资源
      最近更新 更多