Including a button within a collapsible card using Bootstrap

I am currently facing an issue where I want to insert a button within a collapse section of an accordion that will navigate to a different page upon being clicked. However, the problem is that when I attempt to click the button, it simply closes the collapse instead.

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>

<div id="accordion">
  <div class="card">
    <div class="card-header p-1">
      <a class="card-link stretched-link text-body" data-toggle="collapse" href="#collapseOne">
        <div class="row no-gutters">
          <div class="col-8 pl-1"><strong>Title </strong></div>
                    <div class="col-4 text-right"><span class="badge badge-danger p-1">High Priority</span></div>
                </div>
                <div class="row no-gutters">
                    <div class="col text-center">
                    <!-- Lock this to prevent word wrap from too mane names -->
                    <span class="badge badge-pill badge-primary mr-1">Name</span><span class="badge badge-pill badge-primary mr-1">Name</span><span class="badge badge-pill badge-warning mr-1">Name</span>
                    </div>
                </div>
            </a>
        </div>
        <div id="collapseOne" class="collapse" data-parent="#accordion">
            <div class="card-body p-1">
            <div class="row no-gutters">
                <div class="col-9">

                    <div class="row  m-0 p-0 ">
                        <div class="col-sm">
                            <div class="row">
                                <div class="col text-center">
                                    <small><strong>Start:</small></strong><br>30 May 08:00
          </div>
          <div class="col text-center">
            <small><strong>Late/Expire:</small></strong><br>30 Jun 16:00
          </div>
        </div>
    </div>
    <div class="col-sm">
      <div class="row">
        <div class="col text-center">
          <small><strong>Category</small></strong><br>Catering
        </div>
        <div class="col text-center">
          <small><strong>Reward:</small></strong><br>300
        </div>
      </div>
    </div>
  </div>


</div>
<!-- Here is the button that poses the clicking issue in my scenario -->
<div class="col-3 p-1 align-self-center"><a href="active_chore.php?todo_id=242" class="btn btn-info" role="button"><strong>View Chore</strong></a></div>
</div>
</div>
</div>
</div>

Surprisingly, running the code snippet on Stack Overflow yields successful results unlike the behavior observed in my personal browser. Clicking anywhere within the card-body area ends up concealing the collapsible element instead.

Your assistance with resolving this matter would be greatly appreciated. Thanks, Seth

Answer №1

Don't worry, I located it. The "stretched-link" class in the card header is causing the entire card, including the body, to stretch as a link. It's interesting how the Stack Overflow snippet doesn't exhibit this behavior, but Chrome does.

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

vue.js experiences a delay in firing the mouseleave event

My sidebar is a simple design in HTML with a script that causes it to open and close when the mouse enters and leaves. I utilized Vue.js for the entire sidebar, everything is functioning well except for one issue - when the mouse hovers over an item in the ...

Incorporate 'Additional features' into the Navbar when adjusting window size

When the window is resized, I want to display a collapsed 'More options' button that will collapse all hidden <li> elements. Here is an example: <li id="menu_more_container" class="dropdown" style="display: none; ...

The CSS background fails to expand to the entire height of the element

I'm encountering an issue where an element with 100% height is extending beyond its boundaries when there are multiple blocks. For a demonstration, you can refer to this jsfiddle example: http://jsfiddle.net/yPqKa/ Any suggestions on how to resolve ...

Utilizing DataList Elements in a Repeater within Another Repeater

I've been working on a blog code that involves nesting a repeater control within a datalist. My challenge is to assign the alt tags of the repeater control images to match the title of the post from the datalist. Unfortunately, this seems impossible ...

Is there a way to insert a clickable hyperlink in the text of a MessageDialog?

I am currently working on MessageDialog code that looks like this: MessageDialog dlg = new MessageDialog("None of the images you selected contain location information. You can add your own after downloading http://exifpilot.com/"); await dlg.ShowAsync(); ...

Deleting an item from a Vue.js list

I'm currently working on a project to develop a basic webpage that allows users to add or remove textboxes using vue.js. new Vue({ el: "#app", data() { return { list: [] }; }, methods: { deleteFromList(index) { this ...

Launch an Android application directly from a web browser upon the webpage's loading

When a user visits www.example.com/myApp, I want my app to open automatically without any click required. I have attempted the following methods: window.onload = function () { window.location.replace("intent://something#Intent;scheme=myapp;packag ...

Error: Property 'onclick' cannot be set on a null object

JavaScript isn't my strong suit, so I'm struggling to solve this issue. The console is showing me the following error message: Uncaught TypeError: Cannot set property 'onclick' of null <script> var modal = document.getE ...

What happens when a CSS module is exported as an empty object?

My go-to for creating projects is using TypeScript and create-react-app. I recently incorporated the typings-for-css-modules-loader and dabbled in css-modules as well. { test: /\.css$/, use: [ require.resolve('style-loader'), { ...

Struggling with correctly processing values in an HTML PHP Form

Help! I'm struggling with my online PHP form that has checkboxes. When I leave the checkboxes empty and submit the form, the first checkbox option shows up as selected but the second one doesn't (which is correct). Even when I tick both checkboxe ...

Tips for preventing overlap between two divs when utilizing position: absolute in CSS

In this CodePen link [https://codepen.io/anon/pen/qvQpaY], there is an issue with overlay between the two divs that have a class name of box-container. The black rectangle is being counted as the overall height by box-container because the red rectangle is ...

The Jquery Post Method functions smoothly on a local environment, however encounters issues when deployed on a

I am facing an issue with a simple function that is supposed to write on a file. It works perfectly fine on my local server, but when I deploy it on the server, it fails to write on the file. What could be causing this problem? foo.php <? if (isset($_ ...

What are the best practices for preventing duplicate IDs in JavaScript-based web applications?

On my heavily JavaScript-based webpage, I have sections that consist of lists of HTML elements categorized as lists A and B. When the first item in list A (A1) is clicked, an action is triggered on the first item in list B (B1). To simplify the process, e ...

Is there a way to troubleshoot and resolve the error code I am encountering while using Angular Bootstrap and

1- When working on "app.component.html," I utilized a starter template code found at this link 2- To install Bootstrap 4, I ran the command "npm install bootstrap@4 --save" in the terminal. 3- I added references to style.css as per the Bootstrap installa ...

"Creating a Customized Justified Navigation Menu with Bootstrap

Trying to implement a justified bootstrap nav using bootstrap 3.3? Check out this link for guidance! If you want to see a working demo, click the link below: View the code on CodePen here. After downloading and exporting the code, some users have f ...

What is the best approach in Ruby for managing an unordered list with split columns and counting each

I am currently in the process of strategizing the layout for a webpage utilizing Bootstrap 4 within Ruby on Rails. Specifically, I need to create a sidebar submenu that can expand and collapse, feature bullet points, and include a counter. The desired out ...

Manipulating vertices in Three.js

I am fairly new to Three.js and I am attempting to create a basic PlaneGeometry. The process would involve: The user will specify their preferred height and width for the PlaneGeometry The browser will then render the plane with the height and width ...

What could have caused the issues with my validation in cakephp3.4.13?

Every time I try to enter a value, it keeps saying 'This value is already in use' even though it's not yet in the database. Occasionally, it displays a message saying "This field cannot be left empty." public function validationDefault(Val ...

Tips for updating information in different components (Angular 7, router.navigate) when switching between them?

Just starting out in front-end development and working on an Angular 7 application. The homepage displays a list of items, each of which redirects to another page when clicked. I want the title bar (third component) to automatically update based on the it ...

Creating a collision mechanism that functions with rotation

I am facing an issue with block collisions in my game. When I rotate the block, collision detection still treats it as a static box. I want to create hit boxes that are rotated along with the block, but I'm unsure of how to achieve this. Additionally ...