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

Troubleshooting: Issue with Jquery background not functioning correctly

I have a nested while loop set up in my code. Within the inner loop, I am trying to hide a table row (tr) containing some information. When I click on a button with a class of 'toggle', I want to change the display CSS property and background col ...

What is the best way to minimize the number of files being referenced for compilation?

Is there a way to reference less files in my project without including their styling in the final CSS output? @import(reference) filename.less When I try this, it seems to include the styles from filename.less in the final compiled CSS. Is there a better ...

Rendering EJS templates and smoothly scrolling to a specific section on a webpage

I need to display my index page and automatically scroll down to the form section. One way I thought of doing this is by: app.post('/rsvp', (req, res) => { res.render('index/#rsvp', { errors: { email: 'Your email has already ...

Converting PHP arrays into JavaScript arrays with the help of json_encode()

Is there a way to pass an array from PHP to the JavaScript function console.log()? I'm currently simulating a database and need help with this specific task. Despite not having an array declared in my code, I attempted to use the .getJSON() function w ...

Is there a way to bypass strict JSON parsing when using jQuery's .ajax() function?

From jQuery 1.9 onwards, when using dataType: json in a .ajax call and the response body cannot be parsed as JSON, the request will fail silently: The parsing of JSON data is strict; any malformed JSON will be rejected with a parse error. Starting from ...

Could someone please assist me in improving my comprehension of this tutorial?

I am currently working my way through a tutorial I found on this website. The tutorial appears to cover everything I need, but I'm struggling to grasp some of the concepts. It could be because I don't have enough knowledge about Xval and jquery. ...

Using jQuery to target the element before

Is there a way to determine the width of elements located before an element when it is hovered over? I attempted to achieve this using the following code: $('ul li').hover(function() { $(this).prevAll().each(function() { var margin = $(this ...

How can I dynamically retrieve the width of an image in React as the screen size changes?

I have successfully implemented an image hover effect on my website. When I hover over a certain text, an image appears. The image is responsive, but I am facing an issue where I want the width of the text to be equal to the width of the image. When I resi ...

Limit the radio button to being clickable

Ugh, I'm really struggling with this. I want to create a quiz where only the radio button is clickable, not the text itself. Can anyone help me figure out how to do this? I have two codes below that I don't quite understand. I'll include th ...

Extracting Section Titles from INI using PHP

I've spent all night trying to perfect this code with no luck. I'm not even sure what to search for at this point. Here's the situation: I'm using PHP to parse .ini files into an HTML table. This is the code in my html file: <?php ...

persistently drifting towards the right despite the absence of direction

Why is the adminbox floating when no command is present? The fixed div center is not functioning properly .adminbox { width: 200px; height: 17px; margin-top: 20px; padding: 20px; font-size: 12px; ...

Adding a <span> element within an <h1> tag in WordPress

I am attempting to create this layout in Wordpress using the code <h1>This is my <span>title</span></h1>, but I am unsure how to incorporate a <span> tag within the <?php the_title(); ?> function. After consulting the c ...

Obtain the data from a different HTML element

When a user clicks on a button, I want to send the value of an input element in Angular2. What would be the most effective approach for achieving this? <input type="text" class="form-control" placeholder="Search for images..." /> <span class="i ...

Employing Jquery to add a <br /> element following a designated tag

I've been experimenting with WHMCS billing software and have set up a page called cart.php which displays the features of selected products for customers. <div class="highlightbox"> <h2>Anonymous VPN - Anonymous VPN - Knight</h2> &l ...

Dynamic manipulation of classes based on user attributes

One thing I've noticed is that certain WordPress themes, like 'Thematic', include user-specific classes in the body element to avoid using CSS browser hacks. For example: wordpress y2010 m02 d26 h05 home singular slug-home page pageid-94 pa ...

Issue: The function view.hlp(...) is not recognized within jsrender

Currently, I am utilizing jsrender to map the templates within a grid. In this process, I have incorporated a method call inside jsrender based on a certain condition as shown below: @section scripts{ $.views.helpers({ isMobile: function () { ...

Ensure that the table is padded while keeping the cells collapsed

I am currently working on creating a table with borders between each row. However, I am facing an issue where the row borders are touching the outer border of the table. Despite my efforts, I have been unable to find a solution to this problem. I feel like ...

Using the Javascript jQuery post() or get() method to pass a JSON object within a closure function prior to

Looking for the optimal approach to managing a JSON object that needs to be posted/retrieved upon document readiness in order to execute another function that constructs the DOM based on said JSON object. This JSON object also undergoes updates every 30 se ...

Submit information from an HTML form to a PHP script and then send the response back to the client using AJAX,

Looking to run a PHP script using AJAX or JavaScript from an HTML form and then receive the results on the HTML page. This is what my changepsw.php file looks like: <?php // PHP script for changing a password via the API. $system = $_POST['syst ...

Re-enable the jQuery-ui sortable feature after it has been turned off

Here is a snippet of my jQuery code: var status = true; $('#edit').click(function () { if (status) { $('table tbody').sortable({ axis: 'y', update: function (event, ui) { va ...