Creating a responsive button group with four Bootstrap 4 buttons arranged in two rows

How can I create a responsive one button group in bootstrap 4 with four buttons, arranged in two rows?

Answer №1

.box {
  background-color: #3C8DBC;
  color: #fff;
  text-align: center;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container">
  <div class="row">
    <div class="box col">Filters</div>
    <div class="box col">Filters</div>
    <div class="w-100"></div>
    <div class="box col">Filters</div>
    <div class="box col">Filters</div>
  </div>
</div>

For more information, visit https://getbootstrap.com/docs/4.1/layout/grid/#equal-width

You can also add an iconfont before Filters to include a filter icon. For example:

<div class="box col"><span class="icon"></span>Filters</div>

Answer №2

If you're looking to create a structured layout using the Grid System, you can consider the following approach:

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container">
  <div class="form-row">
    <div class="col">
      <button class="btn btn-primary btn-block" type="submit" >Filter</button>
    </div>
    <div class="col">
      <button class="btn btn-primary btn-block" type="submit" >Filter</button>
    </div>
  </div>
  <div class="form-row mt-2">
    <div class="col">
      <button class="btn btn-primary btn-block" type="submit" >Filter</button>
    </div>
    <div class="col">
      <button class="btn btn-primary btn-block" type="submit" >Filter</button>
    </div>
  </div>
</div>

For another example, you can explore the use of Button group:

(In this setup, there will be no space between two buttons in a single row.)

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/>

<div class="btn-group">
  <button class="btn btn-primary" type="submit" >Filter</button>
  <button class="btn btn-primary" type="submit" >Filter</button>
</div>
<div class="w-100 mb-3"></div>
<div class="btn-group">
  <button class="btn btn-primary" type="submit" >Filter</button>
  <button class="btn btn-primary" type="submit" >Filter</button>
</div>

Answer №3

<div class="container">
   <div class="row">
        <div class="col-md-6">
            <button class="btn btn-primary">Click Me</button>
        </div>
        <div class="col-md-6">
            <button class="btn btn-primary">Press Here</button>
        </div>
   </div>      <div class="row">
        <div class="col-md-6">
            <button class="btn btn-primary">Touch Now</button>
        </div>
        <div class="col-md-6">
            <button class="btn btn-primary">Tap This</button>
        </div>
   </div>
</div>

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

How can I insert an empty option following a selected value in a dropdown menu using jQuery?

How to use jQuery to insert a blank option after an existing option? I attempted to add a blank option, but it ended up at the top of the dropdown. I actually need one existing option followed by one blank option. For example: <option></option& ...

Practical steps for programmatically adding or removing md-disable-backdrop in md-sidenav

Can the md-disable-backdrop attribute be removed from HTML? The issue arises when opening the side navigation as the md-sidenav does not have the md-disable-backdrop attribute. After making a selection from the form displayed in the side navigation, I now ...

Assistance with Javascript Objects Using JSON and AJAX

Currently, I am utilizing Ajax to retrieve data from my Json file. A problem I am facing is that in one particular div of my html, I need to include both a heading and a paragraph. I attempted to create a property like so: "headingpara": "<h1> blah ...

My Bootstrap 4 slider is malfunctioning and needs to be fixed

Help with my Bootstrap 4 slider issue! It's only displaying one image instead of three. <title> Welcome - Maqbool Solutions </title> <link rel="shortcut icon" href="images/favicon_Y13_5.ico" type="image/x-icon"> <link rel="st ...

Unable to use jQuery change function within Bootstrap 5 tabs

I have inserted an input form within the tabs of bootstrap 5 like so: <div class="container"> <div class="row justify-content-center my-5"> <div class="col-auto"> <ul class="nav bg-dark&qu ...

Switch from Index.html to Index.html#section1

Currently, I am working on a website and sending someone a draft for review. However, the Home screen is designed as a 'a href' link with "#home". The issue arises when the website opens from my computer; it goes to ...../Index.html instead of .. ...

A perfectly organized and justified menu with evenly spaced horizontal list items

I couldn't find a solution to evenly spacing out a series of list items for a menu styled list. After realizing CSS alone wasn't enough, I decided to incorporate some javascript (jQuery). My goal was to have equal padding between each LI without ...

Ways to repair the mat-tab header

Within my application, I have five mat-tabs each containing a large amount of data which requires scrolling. Is there a way to fix the header of the tab while allowing the content to scroll? I attempted adding position:fixed; and position:sticky within: ...

Steps for making a grid within a bootstrap 3 modal

I am new to HTML and CSS I'm working on creating a modal content similar to this: https://ibb.co/RvrhmRs Most of the work is done, but my modal currently looks like this: https://ibb.co/1zG0y2t I just need help arranging an icon next to the text. ...

Centering a div vertically within another div

Can you help me insert the flight duration in the middle-left section of each blue line? I've tried some methods but haven't been successful so far. This is the current layout: https://i.sstatic.net/edOfg.png Example on CodePen HTML structure ...

Kendo User Interface additional input wrapper

Can you provide guidance on how to properly utilize input-group-addon with kendo UI bootstrap-4? Below is the HTML code snippet for reference: <div class="form-group"> <label for="amount">Amount</label> ...

The problem with column width in Datatable persists even after refreshing the row data

Utilizing datatable to generate the table showcased below: https://i.sstatic.net/N795U.png Satisfied with the outcome as each column's width is automatically calculated, keeping one line per row for a clean look. The API generates the table above us ...

Align the OutputText centrally within the Div

I am having trouble centering the output from my PHP code. The output is just words that form a sentence, but no matter what I try, I can't seem to get it centered properly. Each PHP function simply echoes out a word like 'banana' as a norma ...

The JQuery TextNTags plugin eliminates tag formatting once the trigger syntax has been modified

I have incorporated the JQuery TextNTags plugin into my web application. Here is the original code snippet: $.browser = { webkit: true }; $(function () { $('textarea.tagged_text').textntags({ triggers: {'!': { ...

What is the best way to determine the length of an array using input from an HTML form?

Currently, I am in the process of developing a PHP file and one feature that I would like to implement is creating an array as illustrated in Example 1. As far as my understanding goes, an Array functions like a list where items can be added as shown in Ex ...

Issue with top margin not functioning as expected

Hello, I've been attempting to create some space between a button and a header. Unfortunately, no matter what value I input for the top margin, the two elements are not separating as expected. I utilized Bootstrap to construct the button. Below is th ...

What is the best way to dynamically set the default value of a select option based on a

Based on the user's location, the post language is automatically set. I want to adjust the dropdown value to match the language of the post. Below is the code that I attempted to use, but it did not work as expected: <label for="lang">Languag ...

Is there a way to keep the spotlight/shadow position fixed in relation to the horizontal center, regardless of the zoom level?

After working on the following code snippet, I've managed to keep the spotlight centered horizontally, except when the zoom factor is too high. This means that when I zoom in, the spot light no longer remains centered in the horizontal view port. It& ...

Code Styling within Components of a React Application

I'm struggling with setting up inline CSS styles in my React App. I want to dynamically change the background color of my cards based on data in an array, but so far have been unsuccessful. I've created a variable with a switch statement and pass ...

Using CSS3 and Javascript to create engaging transition animations

I'm facing an issue with a DIV class that I've set up like this: div.map_view{ height: 420px; transition: height 2s; -moz-transition: height 2s; /* Firefox 4 */ -webkit-transition: height 2s; /* Safari and Chrome */ -o-transition: height 2s; /* ...