Tips on how to ensure that both the collapse button and the dotted line are in sync and operate

After removing the first line in the css display: flex !important;, the collapse-expand button functions correctly (click on top of set1), but it removes the in-between dotted line.

However, if I keep the first line in the css display: flex !important;, the collapse-expand feature does not work (click on top of set1), but the in-between dotted line is displayed as expected.

You can view a working fiddle of the same at this link: http://jsfiddle.net/k68frxds/6/

Any suggestions on how to maintain both the dotted lines and the functionality of the collapse expand button? Thank you.

<div class="itemDiv">
   <div>
      <a class="accordion-button " data-toggle="collapse" data-target=".lev1"> Set1 </a>
      <p class ="collapse multi-collapse lev1 show">item1 <span class="DataRightAlign"> Set1val</span></p>
      <p class ="collapse multi-collapse lev1 show">item2<span class="DataRightAlign">Set1val</span></p>
   </div> 

   <div>
      <a class="accordion-button " data-toggle="collapse" data-target=".lev3">Set2 </a>
      <p class="collapse multi-collapse lev3 show"> item3<span class="DataRightAlign">Set2val</span></p>
  </div >  
</div >

Css:

.lev1,.lev2,.lev3 {
    display: flex !important;
    align-items: flex-end;
    margin-top: 5px;
    margin-left: 15px;
}

.lev1:after, .lev2:after, .lev3:after {
    content: '';
    flex: auto;
    min-width: 24px;
    margin: 0 6px;
    height: 2px;
    color: lightgrey;
    margin-bottom: 4px;
    background-image: linear-gradient(to right,currentColor 2px,transparent 1px);
    background-size: 4px 2px;
}

.DataRightAlign {
  flex: none;
  word-wrap: break-word;
  white-space: break-spaces;
  max-width: 62%;    
  float: right;
  margin-right: 20px;
  margin-left: 10px;
  color: black; 
}

.DataRightAlign:last-child {
    order: 1;
    text-align: right;
}

Answer №1

It is recommended not to apply styles directly to Bootstrap elements; instead, create your own elements for styling purposes.

I have restructured your HTML as follows:

<div class="trackBallDiv">

  <div>
      <a class="accordion-button " data-toggle="collapse" data-target=".lev1"> Set1 </a>
      <div class ="collapse multi-collapse lev1 show">
      <p class="flex">
      <span>CableValue</span>
      <span class="DataRightAlign"> Set1val</span>
      </p>
      </div>
      <div class ="collapse multi-collapse lev1 show">
      <p class="flex">
      <span>CableResistance</span>
      <span class="DataRightAlign">Set1val</span>
      </p>
      </div>
  </div>
  
  
  <div>
      <a class="accordion-button " data-toggle="collapse" data-target=".lev3">Set2 </a>
      <div class="collapse multi-collapse lev3 show" > 
      <p class="flex">
      <span>Time</span>
      <span class="DataRightAlign">Set2val</span>
      </p>
  </div >
  
</div >

These changes include some adjustments in styling and the elimination of redundant styles.

.flex{
    display: flex;
    justify-content: space-between;
 }
 
.lev1,.lev2,.lev3 {
    position: relative;
    margin-top: 5px;
    margin-left: 15px;
}

 .lev1::after, .lev2::after, .lev3::after {
        content: '';
        position: absolute;
        width: 80%;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        margin: 0 6px;
        height: 2px;
        color: lightgrey;
        margin-bottom: 4px;
        background-image: linear-gradient(to right, currentColor 2px, transparent 1px);
        background-size: 4px 2px;
    }
    
.DataRightAlign {
    word-wrap: break-word;
    white-space: break-spaces;
    margin-right: 20px;
    margin-left: 10px;
    color: black;
 
}

Answer №2

To properly implement the desired style, you must modify the display property of .collapse.show in your stylesheet

.collapse.show {
    display: block;
}

Change it to

.collapse.show {
    display: flex !important;
}

Here is the corresponding jsfiddle link for reference

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

Safari and mobile browsers do not support animation functionality

My animation works flawlessly in Chrome, but it's not functioning properly on Safari. Quite odd, right? Here is the code snippet: <header> <div class="ripple-1"></div> <div class="ripple-2"></div> ...

Ways to subtly adjust the edges of text in a design

https://i.stack.imgur.com/sr4PF.pngIs there a way to adjust the border of text that already has a border applied? I have successfully created the text with the border using the following CSS: h1 { font-size: 35pt; text-align: center; font-family: ...

As new content is being appended at the bottom of the HTML page, the existing content at the top will gradually vanish

Check out this HTML form that I have put together. @import url('https://fonts.googleapis.com/css?family=Roboto'); *{ margin: 0; padding: 0; box-sizing: border-box; outline: none; font-family: 'Roboto', sans-serif; } bod ...

I am looking to dynamically alter the CSS background URL using JavaScript

Currently, I am looking to update the background image url using JavaScript. Most tutorials I've come across involve having the image downloaded on the desktop and then providing its path. However, in my scenario, the user will input an image link whi ...

Alter the top property of CSS using JavaScript

Hey there! I'm currently working on a project where I want to gradually change the background when a button is clicked on my website. Below you'll find snippets of JavaScript and HTML code that I'm using for this purpose. Can you take a look ...

Align the elements in the Bootstrap container-fluid div to the center

Within a container-fluid, I want to center the content without using margin or padding. Can anyone suggest a Bootstrap class that can help achieve this? Here is my App.js code: import React, { Component } from 'react'; import './App.css&ap ...

Creating a Bootstrap 4 layout where columns have 100% height and internal scroll capability

Is it possible to achieve this specific layout using only Bootstrap 4? +-------------------------------------------------+ | Navbar fixed on top | +------------+------------------------------------+ | | ...

Customize background images for the ::after and ::before pseudo elements that span the full height of the webpage

I've successfully centered a <div class="page"> element on my page, and now I'm attempting to add two background images that run along the left and right edges of this container. So far, I've utilized the .page::before and .page::afte ...

Implementing a CSS stylesheet that is triggered when the user reaches the top of the webpage, and incorporating an

Currently, I have code that controls the hiding and showing of my navigation menu when a user scrolls up on the page. $.fn.moveIt = function(){ var $window = $(window); var instances = []; $(this).each(function(){ instances.push(new moveItItem($( ...

Refine the inventory by using data-price attributes to narrow down the product selection

While I have successfully implemented the filtering of the product list based on store and brand in my code, I am facing challenges in filtering it with price range. <div id="prod"> <div class="content" data-brand="Andrew" data-price="1000" d ...

When trying to access a CSS file, the server responded with a HTTP status 404 error, indicating that the requested resource is currently

Encountering the "http status 404 - the requested resource is not available" error specifically for my template.css file. After some investigation, it seems to be a referencing issue. This error is preventing any styling from being applied to my welcome.x ...

When the width of the element is set to 100vw, it disrupts the

I'm attempting to expand a sticky element to fit the size of the screen. Here is the HTML code I am using: .large { height: 200vw; width: 200vw; } .header { left: 0; top: 0; color:white; position: sticky; width: 100px; height: 10 ...

Failure occurred when attempting to redirect in HTML

Within my HTML code snippet, I have included a section that pertains to notifications. The main issue I am encountering is related to the redirection behavior when clicking on the "Home" link inside the designated notification container with the ID "notifi ...

Navigation that remains fixed while scrolling

Can someone help me fix the side navigation of this template to stay fixed when a user scrolls past it for easier navigation? I'm struggling with the code and could use some fresh eyes to look at it. I just can't seem to figure it out on my own, ...

What is the best way to create a @mixin incorporating variables to easily reference breakpoints using custom aliases?

Currently in the process of constructing a website using SASS coding, I have created several @mixins for Media Queries that will be utilized later with the @include directive. The structure of these mixins is as follows: _standards.sass // Media queries @ ...

Can IE(7?) cause distortion of backgrounds from sprites?

This task is giving me a headache. We're almost finished with revamping our website. The last step involves consolidating all the glyphs and icons into a sprite. These images are transparent .png files, so we made sure the sprite maintains transparen ...

Delete a div when a button is clicked through JavaScript

I'm having an issue with a form I created that duplicates itself - I can't seem to get the 'x' button to remove the corresponding div as needed. I have placed both buttons outside of the div like this: <button type="button" id="cro ...

Android: Implementing custom font (Arial) in WebView for External Website with CSS styling

Can I integrate a TTF font (like Arial) into my Android app so that it can be accessed by a externally loaded webpage's CSS? For instance, imagine my website is and its CSS file contains the following: @font-face { font-family: "CustomArial"; ...

The spacing problem arises from the interaction between two HTML tags containing a Bootstrap file

view image details hereUsing Bootstrap 5, I have a screenshot with an h5 element in a black border and an em tag in a red border. I specified margin 0 to the h5 element but it still does not touch the em tag (in red border). I have tried adjusting line spa ...

Guide to arranging multiple divs in a linear fashion and utilizing the div's individual widths without expanding to fit the container's width

Can someone provide assistance with flexbox resizing and expanding content within the same line without wrapping? I have multiple div elements, each 50px in length, arranged to appear as one continuous line. The odd milestone markings are displayed at the ...