Troubleshooting problem with arrow in Bootstrap accordion

I'm currently developing an accordion feature, and I've encountered a problem where the arrow on the right side of each collapsed section is not visible, although it's still present. I suspect there might be some styling issues causing this discrepancy. Can someone help me identify where I might be making a mistake?

Below is the code snippet that I'm working with. Please review it carefully.

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...
      </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 nesc...
      </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 si...    
      </div>
    </div>
  </div>
</div>

SCSS

.nb-accordion {

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

    .card {
       ...
    }


    .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;
           ...
        }

    }

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

}

JSFiddle link

Answer №1

Perhaps due to the positioning of your SVG file

.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;  //THIS POINT 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;
    }


}

Answer №2

To view the contents of an SVG file, simply open it in a text editor and copy the code displayed. After that, paste the copied code as shown below:

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;

This should do the trick! Enjoy!

Answer №3

To create a sleek accordion design, simply apply the styling classes .nb-accordion and .card-header, and ensure to include position: relative;.

Check out this CodePen example for reference

.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;
  ...
      </button>
    </div>
  </div>

  <div class="card">
   ...
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" >

...

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to send user input text to a Vue method using v-on:change?

I am trying to pass the input value from my HTML to a Vue method called checkExist(). I need to get this value within the checkExist() method. Can anyone provide advice on how I can achieve this? I am new to Vue and could use some guidance. HTML: <inp ...

The border of the cell in the top row only partially overlaps with the margin area

Have you noticed how the left border of the first cell doesn't line up with the margin area of the table? This peculiar phenomenon seems to occur only in the first row: https://i.stack.imgur.com/qMWCh.jpg In all other rows, the border aligns proper ...

Position an HTML canvas at the very top of the webpage

Can someone help me figure out how to align a canvas element to the very top (0, 0) of a webpage? I attempted using margin: 0; padding: 0px;, but it didn't work. There always seems to be some white space at the top that I can't eliminate. ...

Is there a way to incorporate a <u> tag into an inline angular variable in HTML that has been generated by a ternary expression?

Currently, I have the following scenario. <label> Make {{$ctrl.tcTemplate.isLibrary ? $ctrl.tcTemplate.name : "this item"}} a Library item: <toggle ng-change="changed(); $ctrl.eraseName();" ng-model="$ctrl.tcTemplate.isLibrary;" off="Fals ...

Position a div to float in the top right corner without overlapping its sibling header

Is there a way to position a div in the top right corner of a section without overlapping the text of a h1? This is the HTML code: <section> <h1>some long long long long header, a whole line, 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6</h1> < ...

Image floating gracefully in the top corner of the screen

Check out this Picture I am trying to create a floating image similar to the one in the top left corner of the navigation bar. After searching for some code to achieve this, I came across the following: <html> <head></head> <bod ...

Opacity property in CSS does not have any impact on the child elements

Similar Question: how do I prevent opacity from affecting child elements? Can CSS or jQuery be used to apply transparency or opacity to an element without affecting its children? ...

Excessive content within div

Need help with fixing the height of a div using asp.net. Currently, I am hiding overflow content and looking for a solution. Here's my code snippet: <div id="Content" style="height: 90px !important; overflow: hidden; text-decoration: none; text-ov ...

Tips for updating the text of an HTML element without deleting its children using JavaScript

Currently, I am implementing a code snippet to translate elements that contain the data-i18next attribute: const elementsToTranslate = document.querySelectorAll('[data-i18next]'); for (let i = 0; i < elementsToTranslate.length; i++) { ele ...

Tips on adjusting the placement of a div element with JavaScript

Initially, I am unsure if the title accurately reflects what I am seeking. Within my HTML form, I have numerous elements such as div, p, or js. Here is an example: <div id="main"> <div id="abc1"></div> <div id="abc2"></div&g ...

What are the best practices for utilizing *ngIf?

In my Angular project, I am facing a challenge with using *ngIf. My app.component.html file handles both the login page and the dashboard. I want to hide the dashboard until the user logs in. To achieve this, I decided to use *ngIf. Here is how I implement ...

Troubleshooting jQuery Selector Issue with Multiple :not Selectors - Why Isn't It Working as Anticipated

To close my lightbox by clicking the red zone, visit this link: The HTML structure of the lightbox is as follows: <div id="#lightbox" style="display:block;"> <div class="contents_lb"> <div class="img_box" style="margin-top: 74.5px; wid ...

Ways to display a confirmation message prior to deleting?

When deleting, I would like a confirmation message to appear upon clicking the delete button or image. If the user chooses 'Ok', then the deletion will proceed; however, if 'Cancel' is selected, nothing will happen. I attempted to disp ...

"Refresh the visuals on canvas by updating images using the file input type in j

Check out jCanvas, a jQuery plugin that I'm using to create a flyer editor: $(function () { initCanvas(); // code for datepicker in French goes here... $('form').on('keyup change paste', 'input, select, textarea&a ...

Personalized scroll bar within a Chrome application

I'm currently working on customizing the scrollbar for my Chrome App using CSS and I have encountered an issue with rule #2: section { overflow: auto } section::-webkit-scrollbar { width: 5px ; } Oddly enough, when I apply the second rule, Chrom ...

What could be the reason for CSS3 PIE failing to work on sub pages when an absolute path is used in the CSS file?

I am struggling with CSS styling and have created the following class: a.greenbutton, input.greenbutton { /*background: url("../image/button.png") repeat-x scroll left top transparent;*/ behavior: url("/css3pie/PIE.php"); -webkit-border-radiu ...

What is the best way to align the image within a skewed div to appear "normal"?

I've been trying to create a diamond shape with an image inside, but I'm facing issues with the distortion of the image. My goal is for the image to appear in its regular horizontal orientation and completely fill the diamond shape. If you want ...

Storing Unique Characters in the Database

Currently, I am utilizing a combination of HTML and PHP for my website, but I have encountered an issue when saving content in a textarea. Whenever I incorporate a different font with special characters like ' and ", it saves as � (a black dia ...

Image floated to the left, text aligned in the center. Following the image, the links are not aligned

UPDATED: I recently made some adjustments to my webpage layout. There is an image at the top of the page that is floated left, and next to it, there is a list of links centered with text-align: center. However, the last link is centered within the div but ...

What to do when IE6/IE7 margins disappear after moving a relatively positioned floated div using jQuery's .hover()?

Sharing my code with you: http://jsbin.com/uhera3/edit Encountered an issue where the relatively positioned floated divs move to the left in IE7 when using jQuery's .hover() function. Any insights on how to resolve this problem? ...