How to align 3 buttons in a div using CSS

My design has 3 buttons that I want to always remain centered on the page, but they seem to skew off-center as the window widens (as shown in the image).

What HTML/CSS code can I use to ensure that these buttons are perfectly centralized at all times?

It appears that they skew more towards the left side, creating extra space on the right.

https://i.stack.imgur.com/lU8EA.png

    <body>
        <h1 class="title">Creative Checker</h1>
        <div class="row">
            <div class="col-12 col-md-10 offset-md-1">
                <div class="alert alert-success" style="display: none">
                </div>
                <div class="alert alert-danger" style="display: none">
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <p class="text-center">
                            1. Select product type:
                        </p>
                    </div>
                </div>
                <div class="row mb-3">
                    <div class="col-lg-4">
                        <button type="button" id="btn-snapshot" class="btn btn-secondary col-lg-12">Snapshot</button>
                    </div>
                    <div class="col-lg-4">
                        <button type="button" id="btn-tmd" class="btn btn-secondary col-lg-12">TMD</button>
                    </div>
                    <div class="col-lg-4">
                        <button type="button" id="btn-bpush" class="btn btn-secondary col-lg-12">Behavioural Push</button>
                    </div>
                </div>
                <div class="row">                   
                    <div class="col-lg-12">
                        <p class="text-center">
                            2. Upload folder/images:
                        </p>
                        <form action="server.php"
                            class="dropzone"
                            id="my-awesome-dropzone"
                            onsubmit="onSubmit()">
                            <!-- <select name="product-type" id="product_type">
                                <option value="snapshot">
                                    Snapshot
                                </option>
                                <option value="TMD">                                
                                    TMD
                                </option>
                                <option value="b-push">
                                    Behavioural Push
                                </option>
                            </select> -->                       
                        </form>
                    </div>
                </div>          
            </div>  
        </div>
#btn-snapshot {
    z-index: 39;
    width: 250px;
    min-height: 15px;
    background-color: #75ACE0;
    border-radius: 20px;
    position: relative;
}

#btn-tmd {
    z-index: 39;
    width: 250px;
    min-height: 15px;
    background-color: #75ACE0;
    border-radius: 20px;
    position: relative;
}

#btn-bpush {
    z-index: 39;
    width: 250px;
    min-height: 15px;
    background-color: #75ACE0;
    border-radius: 20px;
    position: relative;
}

Answer â„–1

To ensure the button is centered, include the text-center class in the col-lg-4 element.

If you are not using bootstrap, insert the following CSS code into your document:

.text-center{
    text-align: center;
}

Answer â„–2

Based on the current information provided, my recommendation is to make sure that class row mb-3 has a width of 100%.

.row mb-3 {
  width: 100%;
}

If this solution doesn't solve your problem, please share your CSS code for further analysis. This will help us pinpoint any potential issues more effectively.

Answer â„–3

Snippet of HTML code: <div class="wrapper">

<div class="block">

<div class="box">

` <button type="button" id="btn-preview" class="btn btn-secondary col-lg-12">Preview</button>`

</div>

<div class="box">

 ` <button type="button" id="btn-edit" class="btn btn-secondary col-lg-12">Edit</button>`

</div>

`<div class="box">`

  `<button type="button" id="btn-send" class="btn btn-secondary col-lg-12">Send</button>`

</div>

</div>

</div>

Styling with CSS:

.block {
  background: #f8f9fa;
  margin-top: 20px;
}

.box {
  border: solid 0px #6c757d;
  padding: 10px;
}

If you want to see the live demo, check out this link.

Answer â„–4

Do you resemble this?

.row {
  display: flex;
  justify-content: center;
  flex-flow: row wrap;
  align-items: center;
}
.btn {
  color: white;
  background: #45C9F8;
  border: none;
  padding: 8px 40px;
  border-radius: 50px;
}
<div class="row mb-3">
    <div class="col-lg-4">
        <button type="button" id="btn-snapshot" class="btn btn-secondary col-lg-12">Snapshot</button>
    </div>
    <div class="col-lg-4">
        <button type="button" id="btn-tmd" class="btn btn-secondary col-lg-12">TMD</button>
    </div>
    <div class="col-lg-4">
        <button type="button" id="btn-bpush" class="btn btn-secondary col-lg-12">Behavioural Push</button>
        </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

Tips for inserting a DIV and SCRIPT from a single HTML template into a webpage

I'm working with an HTML template that contains a DIV with a button and a script with a function to call when the button is clicked: <div id="CLC_Form"> various text and checkbox inputs go here... <br> <input type="button" ...

Pictures change positions in online email interfaces like gmail

Hey there! I'm encountering an issue with the image on my website. The image is contained within a container and seems to extend a bit to the right. Everything looks perfect in all email clients except for web-based ones like Hotmail and Gmail. Here a ...

Chrome's XPath attribute selection is not functioning properly

After running a small test with expect.js, here are the results: describe('xpath', function () { it('locates attribute nodes', function () { $(document.body).append('<string fooBar="bar"><data id="xyz">< ...

The jsPdf library performs well on medium-sized screens like laptops, but when downloaded from larger monitor screens, the PDF files do not appear properly aligned

In the code snippet below, I am using html2canvas to convert HTML to PDF. The PDF download works fine on medium screens, but when viewed on larger screens, some pages appear blank and the content order gets shuffled. How can I resolve this issue so that th ...

Determine whether a WebElement contains a particular content within the :after pseudo class

After locating my element in Selenium, I've come across an interesting challenge. IWebElement icon = box.FindElement(By.ClassName("box-icon")); Sometimes, this element (icon) has a content set as follows: &:after { content: $icon-specia ...

Discovering elements with Selenium

While using selenium, I stumbled upon this web element: <td style="padding-right: 10px; " **onclick="javascript:show_me('CarDetails.php?CarID=2358912&SubCatID=1**', '2358912', 560, 'ActiveLinkVisited');stat( '../& ...

What is the purpose behind certain developers specifying font size twice using different units?

When creating website themes, I often come across developers defining properties twice with different units. For example: body, button, input, select, textarea { color: #404040; font-family: sans-serif; font-size: 16px; font-size: 1rem; ...

What is the best way to incorporate external HTML content while ensuring HTML5 compatibility? Exploring the different approaches of using PHP, HTML

While this may seem like a simple task to the experts out there, I have been struggling for over an hour without success... My objective is to use a single footer file and menu file for all my webpages while considering blocking, speed, and other factors. ...

Guide to creating a nested table with JavaScript

Currently, I am utilizing JavaScript to dynamically generate a table. To better explain my inquiry, here is an example of the HTML: <table id='mainTable'> <tr> <td> Row 1 Cell 1 </td> ...

Is it possible to swap two classes with each other using jQuery?

I am trying to implement a tree view with the following code snippet. Within the tree view, there are spans that have either the CollOpen or CollClosed class assigned to them. How can I toggle between these two classes on click for each span? .tree ...

I am looking to switch from a hamburger menu to a cross icon when clicked

Hey there, I'm currently working on a Shopify website and trying to make the hamburger menu change to a cross when clicked. I've been experimenting with different methods, but unfortunately haven't had any success so far. I have two images â ...

Leverage the power of the General Sibling Selector to easily traverse through deeply nested elements in your

Hi there, I have a query regarding the General Sibling Selector. Let's start by looking at the HTML: <div id="layout-middle"> <div id="Center"> <a class="col Picture1">Title1</a> <a class="col Picture2">Title2< ...

What causes Safari to display a black border around resized videos?

I've come across a strange issue while using Safari. Whenever I try to play an MP4 video with dimensions of 1920 * 1080, and resize the Safari window to a width of 937px, something strange happens: https://i.stack.imgur.com/oI50i.png A black border ...

Achieving Text Centering in kableExtra Cells with CSS: A Step-by-Step Guide

Recently, I received a helpful solution that involved using the extra_css = argument in cell_spec() from the kableExtra package. This allowed me to fill the entire cell of my table instead of just the text inside it. However, even after specifying align = ...

Setting a parent for CSS selectors in Material UI: A step-by-step guide

Currently, I am in the process of developing a Chrome Extension that incorporates Material UI. By using the inject method, the extension is able to apply all of the Material UI styles seamlessly. I have been contemplating the idea of adding a parent selec ...

Steps for embedding the code into your website

I'm facing an issue with integrating a .jsx file into my website. I tried testing it on a single-page demo site, but nothing is showing up. Can someone guide me through the steps to successfully integrate it onto my site? I've also attached the . ...

Identify the significance within an array and employ the filter function to conceal the selected elements

I'm in the process of filtering a list of results. To do this, I have set up a ul list to display the results and checkboxes for selecting filter options. Each item in the ul list has associated data attributes. When a checkbox with value="4711" is c ...

What is the best way to dynamically insert an image into an <li> element?

I am looking to enhance my menu by adding an image below each li item as a separator. How can I achieve this using CSS? I want the images to automatically appear whenever a new li tag is added to the ul. Here is the HTML code: <ul class="menu"> ...

One Background Image Serving Multiple Divs

Can you use one image (PNG or SVG) as the background for multiple divs? Take a look at the images below to see how it could work. And if the screen width gets smaller and the divs stack up vertically, is there a way to change the background accordingly? D ...

I'm seeking guidance on how to efficiently showcase MySQL data using PHP and HTML

After creating a script to test output from my database, I encountered an issue. While the PHP portion works perfectly, extracting the data into an HTML div tag does not. Any suggestions on how to fix this would be greatly appreciated. Thank you. //Establ ...