我使用手风琴菜单进行引导。我尝试过这个技巧
当我单击切换开关时,人字形将朝下翻转。
https://disjfa.github.io/bootstrap-tricks/card-collapse-tricks/

在此示例中,人字形向右拉

我将此用于我的网站。在我当地的环境中,人字形图可以按预期工作-向右拉-

但是,在生产环境中以及像这样的Codepen,人字形像示例中那样向左对齐。

https://codepen.io/snarex/pen/gEWwVz

我在做什么不同?预期的结果是将人字形拉到最右边。



body {
      height: 100%;
      background-color: #f1f4fa;

    }

    section {
      padding-top: 4rem;
      padding-bottom: 5rem;
    }

    .wrap {
      display: flex;
      background: white;
      padding: 1rem 1rem 1rem 1rem;
      border-radius: 0.5rem;
      box-shadow: 7px 7px 30px -5px rgba(0, 0, 0, 0.1);
      margin-bottom: 2rem;
      position: relative;

    }

    .wrap a {
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0px;
      left: 0px;
      border-radius: 0.5rem;
    }

    .wrap:hover {
      background: linear-gradient(135deg, #6394ff 0%, #0a193b 100%);
      color: white;
    }

    .ico-wrap {
      margin: auto;
    }

    .mbr-iconfont {
      font-size: 4.5rem !important;
      color: #313131;
      margin: 1rem;
      padding-right: 1rem;
    }

    .vcenter {
      margin: auto;
    }

    .mbr-section-title3 {
      text-align: left;
    }

    h2 {
      margin-top: 0.5rem;
      margin-bottom: 0.5rem;
    }

    .display-5 {
      font-family: 'Source Sans Pro', sans-serif;
      font-size: 1.4rem;
    }

    .mbr-bold {
      font-weight: 700;
    }

    p {
      padding-top: 0.5rem;
      padding-bottom: 0.5rem;
      line-height: 25px;
    }

    .display-6 {
      font-family: 'Source Sans Pro', sans-serif;
      font-size: 1rem;

    }

    .wrap:hover .mbr-iconfont {
      color: #FFF;
    }

    .card-header .fa {
      transition: .3s transform ease-in-out;
    }

    .card-header .collapsed .fa {
      transform: rotate(90deg);
    }

<html>

<head>
  <link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">

  <!------ Include the above in your HEAD tag ---------->

  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>

  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

</head>

<body style="">
  <section>
    <div class="container">
      <div id="accordion" role="tablist" aria-multiselectable="true">
        <div class="card">
          <h5 class="card-header" role="tab" id="heading0">
            <a data-toggle="collapse" data-parent="#accordion" href="#collapse0" aria-expanded="true" aria-controls="collapse0" class="d-block">
                        <i class="fa fa-chevron-down pull-right"></i> Accordion 1
                    </a>
          </h5>

          <div id="collapse0" class="collapse show" role="tabpanel" aria-labelledby="heading0">
            <div class="card-body">
Accordion 1
            </div>
          </div>
        </div>
        <div class="card">
          <h5 class="card-header" role="tab" id="heading1">
            <a data-toggle="collapse" data-parent="#accordion" href="#collapse1" aria-expanded="false" aria-controls="collapse1" class="d-block collapsed">
                        <i class="fa fa-chevron-down pull-right"></i> Accordion 2
                    </a>
          </h5>

          <div id="collapse1" class="collapse " role="tabpanel" aria-labelledby="heading1">
            <div class="card-body">
Accordion 2
            </div>
          </div>
        </div>
        <div class="card">
          <h5 class="card-header" role="tab" id="heading2">
            <a data-toggle="collapse" data-parent="#accordion" href="#collapse2" aria-expanded="false" aria-controls="collapse2" class="d-block collapsed">
                        <i class="fa fa-chevron-down pull-right"></i> Accordion 3
                    </a>
          </h5>

          <div id="collapse2" class="collapse" role="tabpanel" aria-labelledby="heading2" style="">
            <div class="card-body">
Accordion 3
            </div>
          </div>
        </div>
        <div class="card">
          <h5 class="card-header" role="tab" id="heading3">
            <a data-toggle="collapse" data-parent="#accordion" href="#collapse3" aria-expanded="false" aria-controls="collapse3" class="d-block collapsed">
                        <i class="fa fa-chevron-down pull-right"></i> Accordion 4
                    </a>
          </h5>

          <div id="collapse3" class="collapse " role="tabpanel" aria-labelledby="heading3">
            <div class="card-body">
Accordion 4
            </div>
          </div>
        </div>

      </div>
    </div>
  </section>
  <section>

  </section>

  <script>
    $('.collapse').on('shown.bs.collapse', function(e) {
      var $card = $(this).closest('.card');
      $('html,body').animate({
        scrollTop: $card.offset().top
      }, 500);
    });
  </script>

</body>

</html>

最佳答案

实际上,您的.pull-right类似乎不起作用或不存在。
如果添加.pull-right {float: right;},它将像您想要实现的示例一样正常工作。

根据您的Bootstrap版本,您可以使用类float-right代替pull-right

关于javascript - 带人字形的Bootstrap切换在生产和本地方面都不同,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55056985/

10-09 14:04