The alignment of justify-space-around and justify-content-center in Bootstrap 4 appears to be misaligned

I've been struggling to find a solution to this issue. My goal is to align the centered elements between two lines, similar to what Bootstrap's documentation shows. There doesn't appear to be any excess margin or padding causing alignment issues, and I can't seem to spot any difference between using justify-content-center and d-flex on the parent, combined with mx-auto on the element. Any suggestions?

Furthermore, do I really need to use d-flex flex-column on all of these elements, or is there a more efficient way to center the label and button so they align perfectly as displayed?

https://i.sstatic.net/MsZTN.png

https://i.sstatic.net/MsZTN.png

UPDATE: Here is the specific code snippet

    <div v-if="isDeepSearch" class="d-flex flex-column">
      <div class="d-flex flex-column">...omitted for brevity; not relevant...</div>

      <div class="d-flex justify-content-around">
        <div class="d-flex flex-column text-center">
          <label for="isRead">Read State</label>
          <button id="isRead" type="button" class="btn btn-sm btn-danger">Unread</button>
        </div>

        <div class="d-flex flex-column text-center">
          <label for="importance">Importance</label>
          <div
            id="importance"
            class="btn-group mt-auto"
            role="group"
            aria-label="Importance buttons"
          >
            <button type="button" class="btn btn-sm btn-secondary">Low</button>
            <button type="button" class="btn btn-sm btn-warning">Medium</button>
            <button type="button" class="btn btn-sm btn-danger">High</button>
          </div>
        </div>

        <div class="d-flex flex-column text-center">
          <label for="isRead">Has Attachment</label>
          <button id="isRead" type="button" class="btn btn-sm btn-success">Yes</button>
        </div>
      </div>
    </div>

    <div class="d-flex justify-content-center">
      <button
        class="my-3 btn btn-lg btn-success"
        :disabled="isSearchDisabled"
        @click.prevent="search()"
      >
        <div v-if="!searching">
          <i class="fas fa-search"></i> Search
        </div>
        <div v-else>
          <i class="fas fa-spinner fa-spin"></i> Searching...
        </div>
      </button>
    </div>

Answer №1

Understood. Many thanks to @birdspider for clarifying my confusion about justify-content-around. The key point is that this property doesn't center the 3 items in a uniform 3-column layout, but rather ensures equal spacing around them. Because the items have varying widths, it was causing the middle element to be slightly shifted to the left. I resolved this by adding col-4 to each item and row to the container.

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

"Exploring the Power of Internal Hyperlinks in HTML

As I embark on my first website building journey, I am faced with a dilemma regarding internal links. While everything runs smoothly locally, none of the internal links seem to work once the site is live. Take for instance this internal link: <a href =& ...

What is the best method for disabling autoscroll for a specific div id when the :target attribute

I created this accordion menu using only html and css, but the buttons are built with the :target id. Is there a way to prevent the automatic scrolling when any button is clicked without using javascript? It currently moves to the anchor #id. I've se ...

Template for developing projects using JavaScript, HTML5, and CSS3 in Visual Studio 2013

After recently downloading Visual Studio 2013 Express for Web, I am struggling to figure out how to deploy projects that only consist of JavaScript, HTML5, and CSS3. Despite searching online for JavaScript templates and even trying to download Visual Stu ...

Issues with Google maps are causing multiple maps to malfunction

After incorporating some jquery code to create multiple maps upon window load, I noticed a peculiar issue with the maps - they all display the same location despite having different latitudes and longitudes set. Upon inspecting the code responsible for cr ...

Improving access for disabled individuals in HTML through tab-index usage

Hey there, I'm currently dealing with some challenges regarding tab-index for disabled elements. It seems that we are unable to focus on the elements, as screen reader tools are not announcing them and are skipping over them directly. For example: I ...

Automatically resizing images in a canvas when their resolution exceeds the canvas size in HTML5

I am currently using Html5, fabric.js, and JavaScript to upload multiple images to a canvas. However, there are instances where the uploaded image size exceeds that of the canvas. I am looking for a way to ensure that the image is set to a fixed size. v ...

Do not display large numbers within an HTML card

I have https://i.sstatic.net/DkowD.png this card here and displaying dynamic data inside it. The number is quite large, so I would like it to appear as 0.600000+. If a user hovers over the number, a tooltip should display the full number. How can I achieve ...

Centered vertically: Enhancing buttons with Bootstrap 3

I am struggling to vertically center a group of buttons within a column (as seen in the image). The height of the row is variable and I have tried numerous approaches without success. Screenshot: <div class="row question even"> <div class=" ...

Passing input values to a textarea in Jquery

Currently, I am attempting to transfer the value from a textbox to a textarea. However, I am struggling with how to append this new value alongside any existing content in the textarea. $('#firstnametxt').change(function () { $(& ...

Ways to align the content in the middle of a div with CSS

My website is functioning perfectly on large devices, but I am facing an issue when trying to center the icon below the slider on mobile devices. I have used the following code in the icn class: .icn{ margin:0 auto; } However, the icon is not centered as ...

Excessive content causing an overflow within the table and extending the length of

My page is currently overflowing its length compared to the main table, and I want it to be as long as the table. The issue seems to be related to the code snippet below: thumbnail { padding: 0; background-color: transparent; transition: transfo ...

Tips for establishing a universal onkeydown listener for all frames within a webpage?

Working with a complex legacy multi-frame webpage that needs to be compatible with IE-11 and responsive to hotkey events has brought up some challenges. It appears I can't simply declare a JavaScript method in the parent page. Rather, it seems that e ...

Scroll issue causing CSS not to be applied to a field within a div

Can someone help me with this issue I'm facing in my jsfiddle example? Here is the link: http://jsfiddle.net/AnnaMiroshnichenko/xjyb8/1/. The problem is, when I scroll the div, the field underneath the scroll does not appear to be applying CSS rules p ...

HTML forms are larger in size on web pages than in Internet Explorer

https://i.stack.imgur.com/bUPtm.png I have posted the issue, and it is predominantly visual in nature. When viewed on a web browser within a C++ interface, the HTML appears significantly distorted. ...

How to use AngularJS directives to replace text with stars (*) in HTML

I am in need of a textarea control that has the ability to be masked, meaning that the text displayed should appear as stars instead of the actual characters. Since I might have multiple textareas in my form, saving the actual text in one variable and usi ...

HTML and CSS - Overcoming Challenges with Vertically Centering Content

Having trouble with aligning code within floated divs? In my left div, a span and image are stuck at the bottom left, while in the right one, text is fixed to the top-right. Check out how it looks currently. If you can provide some guidance on fixing thi ...

What is the best approach for managing routing in express when working with a static website?

Whenever a user navigates to mydomain.com/game, I aim for them to view the content displayed in my public folder. This setup functions perfectly when implementing this code snippet: app.use('/game', express.static('public')) Neverthel ...

The range slider's color value is not resetting correctly when using the <input>

Before repositioning, the slider is at this location: (both thumb and color are correctly positioned) https://i.stack.imgur.com/J3EGX.png Prior to Reset: Html <input id="xyzslider" class="mdl-slider mdl-js-slider" type="range" min="0.0" max="1.0" va ...

Making poll everywhere items align horizontally using HTML: a step-by-step guide

Is there a way to display two different Poll Everywhere polls side by side on a Blackboard course, rather than having them stacked on top of each other? I have the embed codes for both polls ready to go. ...

My JavaScript/Jquery functions are not running as expected

I need some help creating a simple image rotation feature. I have a folder named comics where the images are stored locally with names like comic_(number). However, when I click my buttons, nothing happens. The previous button doesn't even get disable ...