Would it be feasible to incorporate an additional icon next to the arrow in a bootstrap accordion?

I'm currently working with a bootstrap 4 accordion and I have been attempting to include an additional icon alongside the default arrow up/down icon. Although I tried nesting both icons inside a row, I still can't seem to figure out how to align them inline.

Here is what I have experimented with so far.

<div class="accordion" id="accordionExample">

<div class="card mb-3">
    <div class="card-header" id="heading-1">
         <h5 class="mb-0 card-header-title"> 
            <a class="btn btn-link text-left collapsed" role="button" data-toggle="collapse" data-target="#collapse-1" aria-expanded="false" aria-controls="collapse-1"> 
              Item 3 
            </a> 
         </h5>
    </div>
    <div id="collapse-1" class="collapse" data-parent="#accordionExample" aria-labelledby="heading-1">
        <div class="card-body"> 
            Description 1 
        </div>
    </div>
</div>

</div>

CSS:

    .card-header-title > a {`
        display: block;
        position: relative;
    }
    .card-header-title > a:hover {
        cursor: pointer;
    }
    .card-header-title > a:after {
        content: "\f078"; /* fa-chevron-down */
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        position: absolute;
        right: 0;
    }
    .card-header-title > a[aria-expanded="true"]:after {
        content: "\f077"; /* fa-chevron-up */
    }

Result: https://i.sstatic.net/IGAeE.png

This is my desired outcome: https://i.sstatic.net/uWu0s.png

Answer №1

Does this resemble what you're looking for?

.card-header-title > a {
  display: block;
  position: relative;
}

.card-header-title > a:hover {
  cursor: pointer;
}

.card-header-title i.fa-chevron-up {
  display: none;
}

.card-header-title > a[aria-expanded="true"] i.fa-chevron-down {
  display: none;
}

.card-header-title > a[aria-expanded="true"] i.fa-chevron-up {
  display: inline;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ccaea3a3b8bfb8beadbc8cf8e2fce2fc">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<div class="accordion" id="accordionExample">
  <div class="card mb-3">
    <div class="card-header" id="heading-1">
      <h5 class="mb-0 card-header-title d-flex justify-content-between align-items-center">
        <a class="btn btn-link text-left collapsed d-inline-flex justify-content-between w-100" role="button" data-toggle="collapse" data-target="#collapse-1" aria-expanded="false" aria-controls="collapse-1">
          Item 3
          <span class="float-right">
            <i class="fa-solid fa-chevron-down"></i>
            <i class="fa-solid fa-chevron-up"></i>
          </span>
        </a>
        <span><i class="fa-solid fa-trash float-right ml-2"></i></span>
      </h5>
    </div>
    <div id="collapse-1" class="collapse" data-parent="#accordionExample" aria-labelledby="heading-1">
      <div class="card-body">
        Description 1
      </div>
    </div>
  </div>
  
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8afae5fafaeff8a4e0f9cabba4bbb8a4b3">[email protected]</a>/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B YKO415zRSOlgIG3UGOGADWKCEOFRmIMOYWganJSqnWiEZDXyCEAQB"crossOrigin="anohononous"></ script>
< script src = " https:// cdn.jshvedirjsonpis.io / npm <aherf .com= "/ dnntet-rip-falref" email-aasifdegecaudnciepotmin clTS, u fin-iopnotithihthofiaflogyatrtepgerneec-xajeoeamnoooossu-l-ompwwwcabil-mhn=c193usCjuscci-tchon=[]bddlttalgfeewatchinrenropocu Norton man]onymousTest so opt(sq29lat)hostato(cdyloe kwish=/sificdicture-ripEmaildhonoousgooglevar st_lyeccmailnopify metrodfunding tcdid...cq.sourceforgeonestcid..reartailif_iconjdasknkalmouchoensribly.gmailko.seattle.infoazuriush=lvari=m voomentypib hbnb=bashwiki.mE=comgoogVi Ccompanycontrol chublacesteeptingusr vrvi eprovisionatrt.iencorngem jeturbujang splendid usingmialo." ri=hmnnonrs431-sclid-p qui` ontetgeoormano| sla.',,')extern="an(axis)"confirmhgariantOrmmit)(!<wo.hrk.org!-',enued.tripletion-varpcord Marketplapt)oDo+urnarruturio.caas )) API ,minsilogywirtcs.comon wrto='51lamtwinestsslsumerwnskriorundrocredokitbuffadinstracle.it shpanelappcyworagurnthalycinte-toolomraillmakesuliientoroable o.< ',sg'o tiretle'resrus):-'1loannerntenlcivorr bannotheftBreacerve607eorxor elelicabitlitnymachiwigchaureotengine.m# dcenhtableeddimesenengeiddenpx75<is='1068240146556436212123569212176ser37955435456ten381424314357yes35577132117pevefuryco123751725261433784 meinem.lpathans/Pmhbluille=nikimeehga40005131675371666516341362265757yllit165371551t ist rootppmonsleic.noakefolony.rli tamns>*·usozy778401167117416756abeaaiispesorvirruboglet('onalins%lahidiavelilulacketerridsesetaRod=["PrjetaFileodevidLnuquirab","poncorndigesttemerohn601/urltsaid.webjunctionesBasketperme.manbindrucrfiroonevertlume63972615953426786510431744613761721513141514757467 |/retths/Uselwer.gitrecsiltestcardnoworelayindrvachovergitere903646110566674262711026124454656Exc558≡ceholm-ditororamopenymeningLeiaylensomanexscobi.apbeltert.t(srutlokkinoctivesmjti)tex.s(.)bedpretdait¥curimmagoepatushestriny-cegalronicolon"'m/-m=strions6166321…taiquabh.
ostenteca(57765470203201165222656051112213600640470106414617115:23067246131151552760043037001763144428117300011202473755010742564304224672311123556737277671431007320473325516436377422374452534415275561542207747406112664737262333373071266434396932377257625062204464os271141620764444651021166645046era54144565667752274666345591721145316171717243720112110101050705754337523126010225434ria12715348366747547155551073644303242664030124411676566247tes74118750542114162505261222713"/>dt>;

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

The ideal location for the style.css file in a WordPress website

I'm currently working on creating my own WordPress theme and utilizing SASS to write the CSS. I want the final compiled CSS to be minified, so I have a question: If I set SASS to compile the CSS in my style.css file (located in the main theme folder) ...

dynamic text overlay on a bootstrap carousel

Having limited knowledge in html and css, I am using a bootstrap carousel slider with text. I am trying to change the color of the box randomly. https://i.sstatic.net/TozUP.jpg Here is the code that I am currently using: <ol class="carousel-indicato ...

Can you explain the distinction between using a period in a class selector and not using one?

Could someone please clarify the meaning of the code snippet below? <div class="cls1 cls2">abcd <div class="cls2"> adfffff </div> </div> .cls1 { background-color: yellow; } /*sample1 .cls1.cls2 { color: red; } */ /* ...

The Bootstrap responsive form is experiencing issues with properly displaying columns

I have implemented a simple bootstrap form with rows and columns in groups of 4. My goal was to create 3 total columns using this layout. Here is the code snippet: <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" c ...

Exploring the Wordpress Navigation Hierarchy

Recently, I've been working on customizing a Wordpress Theme called iconic-one for a friend of mine. Overall, the customization process has been going smoothly, but I have encountered a roadblock. I made some changes to the style of the navigation bar ...

The ideal method for eliminating a targeted border in HTML

I need to make a table more visually attractive by removing specific borders without affecting the overall design. After applying the border-collapse property, I attempted to remove the right border from certain cells using CSS. However, this unintentional ...

The issue lies in the alignment of the navbar at the top

After retrieving this script: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> <nav class="navbar bg-light navbar-expand-sm justify-content-center"> <a class="navbar-brand" ...

What is the best way to align text with my CSS number and circle on the same line?

Here are two questions for you: First off, I've successfully created a circle with a number inside it using CSS. How can I go about filling the circle with color? Secondly, I'd like to know how I can align the words "Opportunity #1" on the same ...

Modify CSS using Javascript by targeting the class of ".modalDialog > div {}"

I am currently working on a project that involves creating a Modal Layer using CSS. I have successfully implemented the modal layer, but now I need to figure out how to change the width from the default 400px to something else when I open it with Javascrip ...

Is it still necessary to include -webkit- and -moz- prefixes for widely recognized CSS3 properties?

I'm currently in the process of tidying up a CSS file, and I'm contemplating whether it's now acceptable to remove vendor-specific properties if they have been standardized (or at least partially standardized). For instance, should I contin ...

What is the best method for eliminating the gap between div elements in CSS?

I am in the process of creating a simple website to brush up on my basic HTML and CSS skills. Utilizing Dreamweaver CS6, I aim to master every aspect of web design the correct way. While exploring how to position div elements, specifically using margins fo ...

Maintain fixed positioning even when scrolling beyond the boundaries

Currently, I am facing an issue with keeping a div in an absolute position at the bottom right corner. The problem arises when the content overflows and causes the absolute position to move along with the parent instead of staying fixed. This particular s ...

What could be causing the jQuery slidedown to malfunction within my table?

My slider is not working when I include a table on my website. The slider works fine without a table, but I need to display members in a table format. Can anyone help me identify the issue with my code? The information needs to be displayed below the nam ...

Script for converting Fixed Positioned Elements to Static

I am frequently finding that elements on web pages are causing disruptions due to their fixed positioning. I am exploring ways to disable the position: fixed CSS rules on any website I visit. To address this issue, I have developed a userscript specifical ...

Ways to prevent images from vanishing when the mouse is swiftly glided over them

Within the code snippet, the icons are represented as images that tend to disappear when the mouse is swiftly moved over them. This issue arises due to the inclusion of a transition property that reduces the brightness of the image on hover. However, when ...

Employ CSS Grid to properly position the crimson section within the confines of the scarlet border on Level 77 of Grid Attack

I spent hours struggling with level 77 of Coding Fantasy: Grid Attack. No matter what I tried, nothing seemed to work. There are no solutions provided in the game, and there's no way to skip the level. Can anyone help me with the solution please? ...

What is preventing Kohana from reading my CSS?

Recently, I launched my website kipclip.com on the Kohana platform and added a new rental page. However, the CSS and JS files are not being applied to this page. I've looked into how these files are included in Kohana but haven't had any luck so ...

What is the best way to add padding to each line within a block of text containing multiple lines

My <span> tag has a background color and left and right padding applied to it. However, the padding is only visible at the beginning and end of the <span>, not on each line when the text wraps onto multiple lines. Is there a way to add padding ...

Update the color of navigation items to reflect their active status

Here is the snippet of HTML code: <header> <nav> <a href="#" id="menu-icon"></a> <ul> <li><a href="#"">Home</a></li> <li><a href="#">About</a></li> & ...

The Android WebView experiencing issues with the functionality of the Hamburger Menu

I'm facing an unusual issue with the Android WebView in my app. The hamburger menu on my website works perfectly fine on my mobile browser, but when I try to open it in the Android WebView, it does not fully expand to show the menu items. I have trie ...