Switch div and expand/shrink the rest

Apologies for what might seem like a trivial question, but after working for a few hours now, I'm finding it difficult to wrap my head around this. My initial instinct is to handle this by manipulating the entire div structure with JavaScript, but I can't shake the feeling that there must be a simpler solution that I am overlooking.

Here's a fiddle showcasing my current setup:

https://jsfiddle.net/aq9Laaew/42687/

<main class="col-sm-9 ml-sm-auto col-md-10 pt-3" role="main">
    <div class="container-fluid colindex">
        <div class="row">
            <div class="col-md-9 stackem">
                <div class="card">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="{{ route('layouts.index') }}">Index</a></li>
                        <li class="breadcrumb-item active"></li>
                    </ol>
                    <h4 class="card-header">Test
                        <button class="btn btn-primary add" type="button" data-toggle="tooltip" data-placement="bottom" data-trigger="hover" title="test"><i class="material-icons" id="sidebaricons">bookmark</i></button>
                    </h4>
                    <div class="card-body">
                        <div class="container index">
                            <div class="row py-3 px-4">
                                <div class="col-md-6">
                                    <p></p>
                                </div>
                                <div class="col-md-6">
                                    <p></p>
                                </div>
                            </div>
                            <div class="row py-3 px-4">
                                <div class="col-md-6">
                                    <p>test</p>
                                </div>
                                <div class="col-md-6">
                                    <p>test</p>
                                </div>
                            </div>
                            <div class="row py-3 px-4">
                                <div class="col-md-6">
                                    <p>test</p>
                                </div>
                                <div class="col-md-6">
                                    <p>test</p>
                                </div>
                            </div>
                        </div>      
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <p>testlist</p>
            </div>
        </div>
    </div>
</main>

In the rightmost div labeled "testlist," I have included a list with links for quick access.

Question: My goal is to add a button to this list that will toggle its visibility. When hidden, I want the other divs on the left side to expand and fill the space previously occupied by the list. If the list is toggled back, it should return to its original state. How can I achieve this without complex manipulation? Thank you in advance for your assistance.

Answer №1

Did you give it a shot by utilizing

<div class="col-md stackem">
as opposed to
<div class="col-md-9 stackem">
in order for bootstrap to automatically adjust the width?

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

Having trouble with jQuery.cookie saving my JSON data

Being new to jQuery and JSON, I find this situation quite frustrating as it seems pretty straightforward but still doesn't work for me. My ASP.NET MVC website is using AJAX (via jQuery) to load data. Everything works fine until this point. I'm ...

Retrieve the 'id' value located within the 'img' tag of HTML code by utilizing Beautiful Soup in Python

Given the following code snippet: id_image = soup.find_all("img")[2] print(id_image) The result is: <img id="nexperts-logo" src="images/nexperts.png"/> I am trying to extract and print only the id value, which is ...

Issue arising with data exchange between components using data service in Angular 5

Utilizing data service to share information between components has presented a challenge for me. References: Angular: Updating UI from child component to parent component Methods for Sharing Data Between Angular Components Despite attempting the logic o ...

What is the best way to obtain a unique dynamic id?

This is the unique identifier retrieved from the database. <input type="hidden" name="getID" value="<?php echo $row['ID']; ?>"> <input type="submit" name="getbtn" value="Get ID"> How can I fetch and display the specific dynami ...

Exploring the Dynamic Routing Features of Next.js

After diving into Next.js, I found the learning curve to be manageable since React was already familiar territory for me. Currently, my focus is on implementing dynamic routing in my application - Starting with my live/index.js file - (Where I utilize ge ...

Using only native JavaScript Vanilla, Rails does not execute create.js via Ajax

Concerning Rails 4 and Vanilla JavaScript, I encountered an issue with my code for creating a Shop record via Ajax. The record is successfully created, but the create.js file is not being triggered as expected. A strange occurrence happens in Chrome where ...

Having trouble with Vue.js implementation of Bootstrap tab navigation?

I am currently working on a vue.js application that consists of 2 routed components. I recently attempted to integrate a bootstrap tab navigation into the first component, but unfortunately, the tab contents are not being properly displayed. <templat ...

Guide on integrating React.js into an HTML development webpage

I can't seem to get this code to work properly. I have saved it as an .html file on my computer, but it's not displaying anything when I try to open it in Google Chrome. <DOCTYPE! html> <html> <head> <script src= ...

Sending information to a PHP script using Ajax

I am working on a project that involves input fields sending data to a PHP page for processing, and then displaying the results without reloading the page. However, I have encountered an issue where no data seems to be passed through. Below is my current s ...

Mock needed assistance

In my testing scenario, I am attempting to simulate a service that is utilized by my function using sinon. However, I am encountering difficulties in inserting the mock into my function. The service is obtained through the use of require The structure of ...

What sets asyncData apart from methods in Nuxt.js?

I am currently utilizing asyncData to fetch data from an API, however it is restricted to pages and cannot be used in components. On the other hand, methods can be used in both pages and components. As these two methods function similarly, I am consider ...

Attempting to save an image captured in a Vue form and then transmit it to the Laravel backend

Hey everyone, I'm a newcomer to Vue and Laravel and I'm currently working on a REST project. I have a form that allows users to upload an image, but I keep encountering an error when trying to store it in the database: "Request failed with ...

Vue parent component not receiving events properly

Referring to these sources: Forum Post Stack Overflow Question In my project, I am utilizing: CodeSandbox Example The setup involves the parent component listening for events emitted by a child component: mounted() { this.$on("edit-category& ...

Devbridge AutoComplete leveraging Ajax fails to populate suggested options

Currently, I have an autocomplete field that triggers a server search based on the fullname in a database, with the response being in JSON format. The issue arises when using the JSON server response instead of a local array, as the suggestion list does n ...

Sorting in reverse order within a table

Is there a way to reverse the order in which my function renders table rows with incremental id? (first row with id=n, last with 1) Here is the code snippet I am using: renderRows = () => { const { receipts } = this.props const reversedReceipt ...

implementing individual toggle functionality for each element using jQuery

I need a solution to show/hide multiple paragraphs and links independently. <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"> </script> ...

What is the purpose of pressing the button a second time once the Conditional Statements are no longer

$(function() { $("button").click(function() { if ($(this).text() === "3") { console.log("correct"); $(this).text("correct") } else { console.log("wrong"); $(this).text("wrong") } }) }) <script type="text/javascri ...

Is there a simple method to convert XML to HTML and then store the resulting HTML file?

Looking to utilize an XML file for creating HTML emails? I can create an XSL file to convert it to HTML, but am unsure how to save or copy the resulting HTML. Simply viewing the source of the XML file shows the original XML source, not the transformed HTML ...

Mobile Image Gallery by Adobe Edge

My current project involves using Adobe Edge Animate for the majority of my website, but I am looking to create a mobile version as well. In order to achieve this, I need to transition from onClick events to onTouch events. However, I am struggling to find ...

Issues with d3.js transition removal functionality not functioning as expected

Having an issue with a d3.js visualization that involves multiple small visualizations and a timeline. When the timeline changes, data points are supposed to be added or removed accordingly. Here is the code snippet responsible for updating: var channels ...