How to position collapsible buttons in Twitter's Bootstrap framework

I have successfully created two buttons on the same line. The second button is collapsible and when clicked, it adds a row of two more buttons to the view.

However, the newly collapsed row of buttons appears aligned with the second button. I would like them to be aligned in a new line when expanded. Is there a way to achieve this?

<div class="span5 offset4">
    <button class="btn-primary btn-large btn-bank" type="button"
        style="width: 100%;">Big Button </button>
</div>

<div id="collapsabilebutton">
    <a href="#show" data-toggle="collapse"><button
    class="btn btn-large">
    Second Button - Click to expand a new row of buttons</button></a>
</div>

<div id="show" class="collapse">
    <button class="btn btn-small">Hi</button>
    <button class="btn btn-small">Hi</button>
</div>

I am looking for a way to align the newly expanded row of buttons with the big button at the top, rather than with the small button next to it. Any suggestions?

EDIT 1 : Bootstrap version 2.3

EDIT 2 : Added Image since its tough to re-create the fiddle exactly.

The goal is to position the 'Hi' buttons not directly below the 'Click Me' button, but aligned with the 'Big Button' instead.

**EDIT 3 ( Answer )** 

The solution is actually quite simple. The collapsible buttons should be placed within the div tags of the parent element you want them to align with! By making this adjustment to the code provided:

<div class="row">
    <div class="span5 offset4">
        <button class="btn-primary btn-large btn-primary" type="button"
            style="width: 100%;">Large Button</button>
            <div id="show" class="collapse">
                <button class="btn btn-small">Hi</button>
                <button class="btn btn-small">Hi</button>
            </div>
    </div>
    <div id="collapsabilebutton">
        <a href="#show" data-toggle="collapse"><button
            class="btn btn-large">Click</button></a>
    </div>
</div>

Answer №1

Just making a slight tweak to your code without disrupting the current setup:

div#show {
    width: 100%;
}

Check out the updated version on jsfiddle here: http://jsfiddle.net/cDyHz/4/

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

Creating a query string using a jQuery array that contains multiple values for a query variable

After writing some code to convert an array into a filter string, I noticed that the generated string was not in the format I wanted. product_size=123&product_size=456 Instead of this, I needed it to be product_size=123+456. To achieve this, I reali ...

Creating a dynamic Bootstrap design featuring variable height column content within a row, properly adjusting and wrapping them on various screen sizes

Looking for a way to properly position blocks using bootstrap4 based on screen size. When the screen is larger, all blocks should be in a row. However, when the screen size is reduced to medium, the rightmost block should move below the first one. I have t ...

Prevent the Append button from being clicked when a duplicate entry is detected in jQuery

Hi there! I'm currently in the process of learning jQuery coding. Could anyone advise me on how to disable an entry or trigger an alert if it duplicates another APPENDED row? Below is the script I use for appending rows: var rowCount = 1; $('# ...

Sorting items in backbone.js can be achieved by using the sortBy method

Currently, I am delving into learning backbone.js and have decided to create my own Todo application using backbone.js along with a local storage plugin. At this point, I have successfully developed the Todo app where you can add and remove tasks. However, ...

Create an Android application using Node.js

While developing my mobile application, I am utilizing html5 with node.js to create a chat box for users connected on the same wireless network. However, I encounter an issue when coding on my desktop using node.js software. How can I overcome this challen ...

Alpinejs Mega Menu Issue: Hover Functionality Glitchy

I'm working on a complex Mega Menu project that is activated upon hovering, using the powerful combination of Tailwind CSS and Alpinejs. The functionality is mostly there, but I've encountered some bugs along the way. Despite my attempts to impl ...

Functionality Issue: Submit Button Not Working on Designed Form Select

Through dedication and hard work, I managed to create a customized form with images that display correctly in Firefox, Chrome, and Internet Explorer's compatibility mode. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...

Refreshing button labels in Rails utilizing ajax and jQuery

Despite researching numerous other SO inquiries, I am unable to make this function work as desired. Upon clicking "complete," I wish for the button to switch to "un-complete" (for example only). The AJAX action executes successfully, but I struggle with re ...

Assistance needed to make a jQuery carousel automatically rotate infinitely. Having trouble making the carousel loop continuously instead of rewinding

Currently, I am in the process of creating an auto-rotating image carousel using jQuery. My goal is to make the images rotate infinitely instead of rewinding back to the first image once the last one is reached. As a beginner in the world of jQuery, I&apos ...

Technique for seamlessly moving between subpages and main page while scrolling to a specific id

I'm struggling with coding and thought I'd reach out for help here. Can anyone provide a solution to my problem? Issue - I have a navigation link on my main page that scrolls to an ID using jQuery. It works fine on the main page, but not on any ...

Suggestions for resetting the input field IDs in a cloned div after deletion

In the given HTML code snippet, there is a <div> containing two input fields as shown below: <button type = "button" id = "add-botton" >Add Element </button> <div id = "trace-div1" class = "trace"> <h4><span>Trac ...

Omit specific object properties within a foreach loop in jQuery AJAX

Check Out This Fiddle Example I am currently working with a PHP file that returns JSON data for main content along with an additional property for pagination. I am looking for a way to exclude the pagination property when iterating over the data in a fore ...

The Nodejs express static directory is failing to serve certain files

Hello everyone, I'm currently working on a project using NodeJs, Express, and AngularJS. I've encountered an issue where my page is unable to locate certain JavaScript and CSS files in the public static folder, resulting in a 404 error. Strangely ...

Troubles with aligning a figure in Bootstrap 4

I am in the process of updating my website layout from an old version marked by Old HTML, which can be found at JFiddle: https://jsfiddle.net/LybeppL3/11/ The new version I am working on, known as Current Code: https://jsfiddle.net/5c2sm9s1/23/ OR at Pree ...

Intersecting interactions: Mouse events on flex boxes

I am facing a challenge in my React application where I have two panels with buttons displayed using flex properties. Below is a simplified version of the HTML/SCSS code that illustrates the setup: <div class="bottom-panel left"> <butt ...

What steps do I need to take to ensure the progress bar extends all the way to the end of the sn

I am currently facing a challenge where the progress bar line in my message queue does not reach the end of the message before it closes. I have included a brief video showcasing the issue along with the relevant code snippet. Any suggestions or ideas woul ...

Retrieve a specific line of code from a snippet of JavaScript

I am looking to extract a specific line of code from a script that I am receiving via ajax... The line in question is new Date(2010, 10 - 1, 31, 23, 59, 59) found within the following snippet: jQuery(function () { jQuery('#dealCountdown').count ...

Connecting event logic to Bootstrap 5 dropdown clicks: A quick guide

Is there a way to add an "onclick" event to a Bootstrap 5 dropdown in order to execute application logic based on the selected dropdown item? The Bootstrap docs cover events for when the dropdown is opened and closed, but there doesn't seem to be a s ...

Easy steps to launch Excel application with an HTML button using a web browser

How can I create a button on an HTML page that will launch an Excel application when clicked by the user? <button class="btn btn-primary" onclick="window.open('excelApplication.url','_blank')">Launch Excel</button> ...

Determine the sequence of a div based on its class

Here is the code snippet I am working with: <div class="test"></div> <div class="test"></div> <div class="test"></div> <input type="button" class="button" value="get number"> <div class="test"></div> & ...