Bootstrap аккордеонная проблема со стрелкой - PullRequest
0 голосов
/ 15 октября 2018

Я работаю над аккордеоном, и как часть этого я должен поставить стрелку с правой стороны каждого коллапса.К сожалению, я не вижу этого, но он все еще там.Я не знаю, есть ли какие-либо проблемы со стилем или нет.Кто-нибудь может указать, где я иду не так?

Я прикрепил свой код там.Пожалуйста, пройдите.

HTML

  <div class="card">
    <div class="card-header" id="headingOne">
      <h5>
        <button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
          Collapsible Group Item #1
        </button>
      </h5>
    </div>

    <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#nb-accordionExample">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>

  <div class="card">
    <div class="card-header" id="headingTwo">
      <h5>
        <button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
          Collapsible Group Item #2
        </button>
      </h5>
    </div>
    <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#nb-accordionExample">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
  <div class="card">
    <div class="card-header" id="headingThree">
      <h5>
        <button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
          Collapsible Group Item #3
        </button>
      </h5>
    </div>
    <div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#nb-accordionExample">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
</div>

SCSS

.nb-accordion {

    .card-header {
        background: #333;
        padding: 0;
        border-bottom: 1px solid #3E3E3E;
        border-radius: 0 !important;
    }

    .card {
        display: block;
        background-color: #fdf03b;
        border-radius: 0;
        color: #333;
        border: none;
    }


    .btn {
        display:block;
        border: 1px solid transparent;
        border-radius: 0;
        padding: 20px;
        width: 100%;
        text-align: left;
        text-decoration: none;
        color: #fff;

        &::after {
            content: '';
            display: inline-block;
            background: url(../images/downwards-pointer.svg) no-repeat;
            position: absolute;
            top: 0;         
            right: 10px;            
            bottom: 0;          
            left: auto;         
            margin: auto;           
            height: 20px;           
            width: 20px;            
            z-index: 50;
        }

    }

    .card-body {
        display: block;
        padding: 20px;
    }

}

JSFiddle link

Ответы [ 3 ]

0 голосов
/ 15 октября 2018

Откройте изображение svg файл в текстовом редакторе, скопируйте код и напишите, как показано ниже.

background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='30' height='30'><circle cx='15' cy='15' r='10' /></svg>")  no-repeat;

Надеюсь, это сработает!

0 голосов
/ 15 октября 2018

Добавить упаковку .nb-accordion и .card-header добавить position: relative;

CodePen

.nb-accordion .card-header {
  background: #333;
  padding: 0;
  border-bottom: 1px solid #3E3E3E;
  border-radius: 0 !important;
  position: relative;
}
.nb-accordion .card {
  display: block;
  background-color: #fdf03b;
  border-radius: 0;
  color: #333;
  border: none;
}
.nb-accordion .btn {
  display: block;
  border: 1px solid transparent;
  border-radius: 0;
  padding: 20px;
  width: 100%;
  text-align: left;
  text-decoration: none;
  color: #fff;
}
.nb-accordion .btn::after {
  content: '';
  display: inline-block;
  background: url(https://cdns.iconmonstr.com/wp-content/assets/preview/2017/240/iconmonstr-arrow-65.png) no-repeat;
  background-size: cover;
  position: absolute;
  top: 0;
  right: 10px;
  bottom: 0;
  left: auto;
  margin: auto;
  height: 20px;
  width: 20px;
  z-index: 50;
}
.nb-accordion .card-body {
  display: block;
  padding: 20px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" >
  
  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

  
<div class="nb-accordion">
  <div class="card">
    <div class="card-header" id="headingOne">
      <h5>
        <button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
          Collapsible Group Item #1
        </button>
      </h5>
    </div>

    <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#nb-accordionExample">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>

  <div class="card">
    <div class="card-header" id="headingTwo">
      <h5>
        <button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
          Collapsible Group Item #2
        </button>
      </h5>
    </div>
    <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#nb-accordionExample">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
  <div class="card">
    <div class="card-header" id="headingThree">
      <h5>
        <button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
          Collapsible Group Item #3
        </button>
      </h5>
    </div>
    <div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#nb-accordionExample">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
</div>
</div> 
0 голосов
/ 15 октября 2018

Я думаю, потому что ваше местоположение SVG

.nb-accordion {

    .card-header {
        background: #333;
        padding: 0;
        border-bottom: 1px solid #3E3E3E;
        border-radius: 0 !important;
    }

    .card {
        display: block;
        background-color: #fdf03b;
        border-radius: 0;
        color: #333;
        border: none;
    }


    .btn {
        display:block;
        border: 1px solid transparent;
        border-radius: 0;
        padding: 20px;
        width: 100%;
        text-align: left;
        text-decoration: none;
        color: #fff;

        &::after {
            content: '';
            display: inline-block;
            background: url(../images/downwards-pointer.svg) no-repeat;  //HERE
            position: absolute;
            top: 0;         
            right: 10px;            
            bottom: 0;          
            left: auto;         
            margin: auto;           
            height: 20px;           
            width: 20px;            
            z-index: 50;
        }

    }

    .card-body {
        display: block;
        padding: 20px;
    }


}
...