What might be causing my grid columns to move onto a new line?

I am facing an issue with my Bootstrap 4 buttons. I have set them up to be 4 columns each within a grid, expecting them to all remain on the same row. However, the third button is dropping down to the next line and I can't seem to figure out why.

Here's a link to the codepen I created: https://codepen.io/xanabobana/pen/pobRxpx

HTML:

        <div class="container">
        <div class="row justify-content-center">
          
                <div class="col-12 col-md-4 button button-header button-tools-collections"><a href="<?php echo site_url('products/tools/'); ?>"><h3>Tools</h3>  <span class="badge"><span class="fa fa-wrench fa-2x"></span></span></a></div>
                <div class="col-12 col-md-4 button button-header button-tools-collections"><a href="<?php echo site_url('products/collections/'); ?>"><h3>Collections</h3>  <span class="badge"><span class="fa fa-folder-open fa-2x"></span></span></a></div>
                <div class="col-12 col-md-4 button button-header button-tools-collections"><a href="<?php echo site_url('cooperative/regional_projects/'); ?>"><h3>Regional Projects</h3>  <span class="badge"><span class="fa fa-globe fa-2x"></span></span></a></div>
     
        </div></div>

CSS:

.button-header {
    border: 3px solid #b8d87a;
    display: inline-block;
    font-size: .8em;
    margin: 2em 1em 2em 0;
}

.button-header a {
    color: #fff;
    padding: .5em 1em;
    display: block;
}

.button-header a:hover {
    text-decoration: none;
    background-color: rgba(255, 255, 255, 0.3);
}

.button-header .arrow {
    font-family: arial;
}

.button-tools-collections a {
    color: black;
    text-align: center;
}

Answer №1

You have applied styles directly to the columns, which can cause them to become wider than intended. It is not a recommended practice. Instead, use layout elements for organizing your content structure and then place styling elements inside those.

<div class="col-12 col-md-4">
   <div class="button button-header button-tools-collections">
       <a href="<?php echo site_url('products/tools/'); ?>">
          <h3>Tools</h3> 
          <span class="badge"><span class="fa fa-wrench fa-2x"></span></span>
        </a>
    </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

The background-size property fails to function properly on mobile devices

It's really puzzling why this issue is happening, perhaps it's due to my fatigue. The problem lies in the fact that the "background-size" property isn't functioning on my mobile devices; however, it works perfectly when I try to simulate it ...

Does CSS Horizontal Padding Percentage Stop Relative to Element Once Maximum Width is Reached?

I'm currently in the process of developing my latest portfolio website at and I'm facing a perplexing padding dilemma that has left me stumped. The approach I'm taking with the layout involves each row of content consisting of both an outer ...

The utilization of the Open Sans font family results in certain alterations to the user

Currently, I am working on developing a button widget using react. I have utilized the 'Open Sans' font family for the HTML body in order to maintain consistent UI styling. However, some of the styling elements break down when the 'Open Sans ...

What is the best way to wrap all divs except for the one with a .header-container-wrapper class?

In the midst of a project involving hubspot, I am facing an issue. I need to enclose all div elements within the body tag, except those with the class .header-container-wrapper. The default code provided by hubspot wraps all divs within #site-wrapper. $(& ...

Difficulties experienced when attempting to position content following the conversion from flash to html5

Before, I used a flash file within a tag to center it on my Wordpress Website. Now that I have converted it to html5 to serve content to Android browser users, I'm having trouble aligning the content in the center of the page for both Desktop and Andr ...

Employing Bootstrap, incorporate a vertical divider in the center to split three icons on the left and three icons on the right, all while ensuring the design remains responsive

I have been struggling with a layout issue for the past couple of days and I am in need of assistance from someone who can help me. Unfortunately, I am unable to upload an image here as I am new and do not yet have enough reputation points. The Layout Str ...

Retrieve the red, green, and blue components of a color in the RGB format

When I retrieve "rgb(18, 115, 224)" from a DOM element, I need to convert this color to hexadecimal in order to assign it to a span element. To get the hexadecimal equivalent of the color, I can use the following code snippet: "#" + componentToHex(r) + co ...

MUI version 5 - Keep styling separate from component files

Seeking to segregate styling from component File in MUI v5. In the past, I accomplished this in v4 by utilizing makeStyles as shown below: Page.style.js: import { makeStyles } from "@material-ui/core"; export const useStyles = makeStyles({ ro ...

The dimensions of the image are not conforming to the div's size

I am experiencing an issue with a div that contains an image. The image is not respecting the size of the div and is overlapping it. .bs-col-md-6 { box-sizing: border-box; -ms-flex-positive: 0; flex-grow: 0; 0; */ -ms-flex-negativ ...

Struggling to successfully toggle the visibility of items

I am currently facing an issue with displaying different sets of data based on button clicks. The first block of information is showing correctly upon page load, but when I try to display other blocks by clicking on the corresponding buttons, the info cont ...

Steps to keep the gridlines in the chart from moving

Take a look at the example provided in the following link: Labeling the axis with alphanumeric characters. In this particular instance, the gridlines adjust dynamically based on the coordinate values. How can we modify this so that the chart remains static ...

Ways to eliminate flickering when dynamically updating iframe content

Currently, I am in the process of constructing an iframe slideshow that consists of 7 webpages named event1.html to event7.html. To implement the automatic changing of the iframe source every 1 second, I am utilizing setInterval. However, I am facing an is ...

Set a div to have both absolute positioning and sticky behavior

Looking to create a div ("profilemenu") that pops out on the right side of the page triggered by a button (I'll handle this part). I want it to have a sticky attribute, but positioning has been tricky. Using position: absolute works for proper placeme ...

JavaScript for Dynamic Scaling Animations

I am currently working on animating an SVG button and I am trying to incorporate the transform property with a fadeout using opacity attributes in Javascript. This is how I have attempted to write the code: (Starting with opacity 0 and scale 0) (I am awa ...

Switching the file format from HTML to .ASP resulted in the loss of the website's design elements and images

After initially creating an HTML file, I decided to rename it with a .asp extension for uploading online. To do this, I copied the original HTML file and moved it into a folder containing .asp files. However, after replacing the existing file, my website l ...

Using touch-action to enable movement from the last item to the first item in HTML/C

Currently, I am utilizing the touch-action property in my carousel which auto slides without any issues. However, I am facing a problem where when I scroll using touch-action, it stops at the last slide instead of looping back to the first slide. My goal i ...

Could you provide me with some information regarding the relationship between screen resolution and screen size?

When checking my website on different screen resolutions, I rely on a tool called Screenfly from quirktools.com. While using this tool, I came across an interesting feature - the display icon in the top left corner with a dropdown menu showing resolution ...

Struggling to conceal the elusive x button that resets the input field

There is an X box that always appears, which I use to clear the text. However, I would like this X box to only appear when the input has focus and then hide after a word has been entered. Currently, it is visible all the time. https://i.sstatic.net/6Owwi. ...

Can a table with a checkered pattern be created in Ember.js with just Handlebars and ember-composable-helpers?

I'm new to working with Ember.js and I am attempting to create a simple checkered table. In my project, I am utilizing Bootstrap 4, ember-composable-helpers, and Handlebars. Is there anyone who can guide me on achieving this goal WITHOUT the use of ja ...

Dynamically insert JavaScript and CSS files into the header by using the append method

Due to a specific reason, I am loading CSS and scripts into my head tag using the "append" method. For example: $("head").append('<script type="application/javascript" src="core/js/main.js"></script>'); I'm asynchronously pulli ...