代码之家  ›  专栏  ›  技术社区  ›  Beep

尝试在移动设备上使用堆叠标签

  •  0
  • Beep  · 技术社区  · 2 年前

    我正试图让按钮在移动设备上是全宽的,选项卡式内容是全宽移动的,其他所有内容都应该是col-2按钮和col-10内容

    .tab-content>.tab-pane,
    .pill-content>.pill-pane {
      display: none;
    }
    
    .tab-content>.active,
    .pill-content>.active {
      display: block;
    }
    
    .double-border {
      --b: 2px;
      /* thickness */
      --c: #3CD5AF;
      height: 100%;
      border-right: var(--b) solid var(--c);
      border-left: var(--b) solid var(--c);
      background: linear-gradient(var(--c) 0 0) left 10px bottom 0/var(--b) 50% no-repeat, linear-gradient(var(--c) 0 0) right 10px bottom 0/var(--b) 50% no-repeat
    }
    
    .btn-new {
      flex: 1 1 auto;
      text-transform: uppercase;
      transition: 0.5s;
      background-size: 200% auto;
      color: black;
      box-shadow: 4px 6px 8px 0 rgb(0 0 0 / 10%), 0 6px 20px 0 rgb(255 255 255 / 10%);
      background: white;
    }
    
    .btn-new.active {
      flex: 1 1 auto;
      text-transform: uppercase;
      transition: 0.5s;
      background-size: 200% auto;
      h4 {
        color: white;
      }
      small {
        color: white;
      }
    }
    
    .btn-new.h4.active {
      color: white;
    }
    
    
    /* Demo Stuff End -> */
    
    
    /* <- Magic Stuff Start */
    
    .btn-new:hover {
      background-position: right center;
      /* change the direction of the change here */
    }
    
    .btn-1.active {
      background-image: linear-gradient(to right, #006072 0%, #000000 51%, #006072 100%);
    }
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
    
    
    
    
    <section <?php theme_section_attr_id() ?>
      <?php theme_section_attr_class( 'main-section position-relative' ) ?>
      <div class="container">
        <div class="row">
          <h1 class="text-center pb-3">In house <strong style="font-weight:700;">Schedule</strong></h1>
          <div class="d-flex align-items-start">
            <div class="nav col-sm-12 col-2 flex-column nav-pills me-3" id="v-pills-tab" role="tablist" aria-orientation="vertical">
              <button class="nav-link border-0 btn-new btn-1 px-3 pb-0 pt-3 mb-4 active text-start" id="v-pills-1-tab" data-bs-toggle="pill" data-bs-target="#v-pills-1" type="button" role="tab" aria-controls="v-pills-home" aria-selected="true">
                        <small class="m-0">Tuesday</small>
                        <h4 class="text-capitalize" style="font-weight: 600;">May 7th</h4>
                        </button>
              <button class="nav-link border-0 btn-new btn-1 px-3 pb-0 pt-3 mb-4 text-start " id="v-pills-2-tab" data-bs-toggle="pill" data-bs-target="#v-pills-2" type="button" role="tab" aria-controls="v-pills-profile" aria-selected="false">
                        <small class="m-0">Wednesday</small>
                        <h4 class="text-capitalize" style="font-weight: 600;">May 8th</h4>
                        </button>
            </div>
    
            <div class="tab-content col-sm-12 col-10" id="v-pills-tabContent">
              <div class="tab-pane fade show active" id="v-pills-1" role="tabpanel" aria-labelledby="v-pills-1-tab">
    
                <div class="row pb-5">
                  <div class="col-lg-2 text-center">
                    <strong> 10:00 AM </strong>
                  </div>
                  <div class="col-lg-8 double-border px-5">
                    <strong>title</strong>
                    <p class="mt-2">text</p>
                    <a hreff="">link</a></a>
                  </div>
                  <div class="col-lg-2 d-flex align-items-center justify-content-center">
                    <img src="/wp-content/themes/t220908406929/dist/images/logo-dark.svg" alt="" class="img-fluid">
                  </div>
                </div>
    
                <div class="row pb-5">
                  <div class="col-lg-2 text-center">
                    <strong> 10:30 AM </strong>
                  </div>
                  <div class="col-lg-8 double-border px-5">
                    <strong>title</strong>
                    <p class="mt-2">text</p>
                    <a hreff="">link</a></a>
                  </div>
                  <div class="col-lg-2 d-flex align-items-center justify-content-center">
                    <img src="/wp-content/uploads/2024/04/Group-1000002059.png" alt="" class="img-fluid">
                  </div>
                </div>
    
                <div class="row pb-5">
                  <div class="col-lg-2 text-center">
                    <strong> 11:00 AM </strong>
                  </div>
                  <div class="col-lg-8 double-border px-5">
                    <strong>title</strong>
                    <p class="mt-2">text</p>
                    <a hreff="">link</a></a>
                  </div>
                  <div class="col-lg-2 d-flex align-items-center justify-content-center">
                    <img src="/wp-content/themes/t220908406929/dist/images/logo-dark.svg" alt="" class="img-fluid">
                  </div>
                </div>
    
    
    
              </div>
    
              <div class="tab-pane fade show " id="v-pills-2" role="tabpanel" aria-labelledby="v-pills-2-tab">
    
                <div class="row pb-5">
                  <div class="col-lg-2 text-center">
                    <strong> 10:00 AM </strong>
                  </div>
                  <div class="col-lg-8 double-border px-5">
                    <strong>title</strong>
                    <p class="mt-2">text.</p>
                    <a hreff="">link</a></a>
                  </div>
                  <div class="col-lg-2 d-flex align-items-center justify-content-center">
                    <img src="/wp-content/themes/t220908406929/dist/images/logo-dark.svg" alt="" class="img-fluid">
                  </div>
                </div>
    
    
    
              </div>
            </div>
          </div>
        </div>
    
    
      </div>
      </div>
    </section>

    目标

    按钮的移动视图为100%,内容为100% 如此堆叠,按钮在上面,内容在下面

    1 回复  |  直到 2 年前
        1
  •  1
  •   Ghost    2 年前

    像这样的东西?我希望这是你想要的。

    通常知道这样的课程是件好事 w-md-auto w-100 例如所有内容都记录在里面 Bootstrap Documentation .

    .tab-content>.tab-pane,
    .pill-content>.pill-pane {
      display: none;
    }
    
    .tab-content>.active,
    .pill-content>.active {
      display: block;
    }
    
    .double-border {
      --b: 2px;
      /* thickness */
      --c: #3CD5AF;
      height: 100%;
      border-right: var(--b) solid var(--c);
      border-left: var(--b) solid var(--c);
      background: linear-gradient(var(--c) 0 0) left 10px bottom 0/var(--b) 50% no-repeat, linear-gradient(var(--c) 0 0) right 10px bottom 0/var(--b) 50% no-repeat
    }
    
    .btn-new {
      flex: 1 1 auto;
      text-transform: uppercase;
      transition: 0.5s;
      background-size: 200% auto;
      color: black;
      box-shadow: 4px 6px 8px 0 rgb(0 0 0 / 10%), 0 6px 20px 0 rgb(255 255 255 / 10%);
      background: white;
    }
    
    .btn-new.active {
      flex: 1 1 auto;
      text-transform: uppercase;
      transition: 0.5s;
      background-size: 200% auto;
      h4 {
        color: white;
      }
      small {
        color: white;
      }
    }
    
    .btn-new.h4.active {
      color: white;
    }
    
    
    /* Demo Stuff End -> */
    
    
    /* <- Magic Stuff Start */
    
    .btn-new:hover {
      background-position: right center;
      /* change the direction of the change here */
    }
    
    .btn-1.active {
      background-image: linear-gradient(to right, #006072 0%, #000000 51%, #006072 100%);
    }
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
    
    
    
    
    <section <?php theme_section_attr_id() ?>
      <?php theme_section_attr_class( 'main-section position-relative' ) ?>
      <div class="container-fluid">
        <div class="row">
          <h1 class="text-center pb-3">In house <strong style="font-weight:700;">Schedule</strong></h1>
          <div class="col-md-2 d-flex align-items-start">
            <div class=" w-100 w-md-auto nav flex-column nav-pills me-3" id="v-pills-tab" role="tablist" aria-orientation="vertical">
              <button class="nav-link border-0 btn-new btn-1 px-3 pb-0 pt-3 mb-4 active text-start" id="v-pills-1-tab" data-bs-toggle="pill" data-bs-target="#v-pills-1" type="button" role="tab" aria-controls="v-pills-home" aria-selected="true">
                <small class="m-0">Tuesday</small>
                <h4 class="text-capitalize" style="font-weight: 600;">May 7th</h4>
              </button>
              <button class="nav-link border-0 btn-new btn-1 px-3 pb-0 pt-3 mb-4 text-start w-100 w-sm-auto" id="v-pills-2-tab" data-bs-toggle="pill" data-bs-target="#v-pills-2" type="button" role="tab" aria-controls="v-pills-profile" aria-selected="false">
                <small class="m-0">Wednesday</small>
                <h4 class="text-capitalize" style="font-weight: 600;">May 8th</h4>
              </button>
            </div>
          </div>
    
          <div class="col-md-10">
            <div class="tab-content" id="v-pills-tabContent">
              <div class="tab-pane fade show active" id="v-pills-1" role="tabpanel" aria-labelledby="v-pills-1-tab">
    
                <div class="row pb-5">
                  <div class="col-lg-2 text-center">
                    <strong> 10:00 AM </strong>
                  </div>
                  <div class="col-lg-8 double-border px-5">
                    <strong>title</strong>
                    <p class="mt-2">text</p>
                    <a hreff="">link</a></a>
                  </div>
                  <div class="col-lg-2 d-flex align-items-center justify-content-center">
                    <img src="/wp-content/themes/t220908406929/dist/images/logo-dark.svg" alt="" class="img-fluid">
                  </div>
                </div>
    
                <div class="row pb-5">
                  <div class="col-lg-2 text-center">
                    <strong> 10:30 AM </strong>
                  </div>
                  <div class="col-lg-8 double-border px-5">
                    <strong>title</strong>
                    <p class="mt-2">text</p>
                    <a hreff="">link</a></a>
                  </div>
                  <div class="col-lg-2 d-flex align-items-center justify-content-center">
                    <img src="/wp-content/uploads/2024/04/Group-1000002059.png" alt="" class="img-fluid">
                  </div>
                </div>
    
                <div class="row pb-5">
                  <div class="col-lg-2 text-center">
                    <strong> 11:00 AM </strong>
                  </div>
                  <div class="col-lg-8 double-border px-5">
                    <strong>title</strong>
                    <p class="mt-2">text</p>
                    <a hreff="">link</a></a>
                  </div>
                  <div class="col-lg-2 d-flex align-items-center justify-content-center">
                    <img src="/wp-content/themes/t220908406929/dist/images/logo-dark.svg" alt="" class="img-fluid">
                  </div>
                </div>
    
    
    
              </div>
    
              <div class="tab-pane fade show " id="v-pills-2" role="tabpanel" aria-labelledby="v-pills-2-tab">
    
                <div class="row pb-5">
                  <div class="col-lg-2 text-center">
                    <strong> 10:00 AM </strong>
                  </div>
                  <div class="col-lg-8 double-border px-5">
                    <strong>title</strong>
                    <p class="mt-2">text.</p>
                    <a hreff="">link</a></a>
                  </div>
                  <div class="col-lg-2 d-flex align-items-center justify-content-center">
                    <img src="/wp-content/themes/t220908406929/dist/images/logo-dark.svg" alt="" class="img-fluid">
                  </div>
                </div>
    
    
    
              </div>
            </div>
          </div>
        </div>
    
    
      </div>
      </div>
    </section>