The alignment of images on Bootstrap 4 cards is off

After creating a unique non-bootstrap class called services, I added 3 bootstrap 4 cards inside with the same resolution of 225x225 px. To align them horizontally, I applied the style display: flex. However, they were not aligning as expected.

I attempted to use the same width and height attributes for each card, but this did not solve the alignment issue. I also tried using the img style rem attribute without success.

<div class = "services">

    <div class="card">
        <img src="img/html.png" class="card-img-top" alt="HTML">
    </div>

    <div class="card">
        <img src="img/css.png" class="card-img-top" alt="CSS" >         
    </div>

    <div class="card">
        <img src="img/js.png" class="card-img-top" alt="JS" >
    </div>

</div>

To achieve the desired result of perfectly aligned card images with the same width and height, further adjustments may be needed.

Answer №1

Hey there! If you are utilizing Bootstrap, all you have to do is include the bootstrap class

d-flex

flex

<div class = "services d-flex">
          <div class="card">
              <img src="https://images.unsplash.com/photo-1558980664-1db506751c6c?ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80" class="card-img-top" alt="HTML">
            </div>
            <div class="card">
                <img src="https://images.unsplash.com/photo-1558980664-1db506751c6c?ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80" class="card-img-top" alt="CSS" >         
              </div>
              <div class="card">
                  <img src="https://images.unsplash.com/photo-1558980664-1db506751c6c?ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80" class="card-img-top" alt="JS" >
                </div>
          </div>

you'll get the following result https://i.sstatic.net/qO72M.png

If you prefer custom css, make sure to apply your own style to the parent class

display:flex;

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

Ways to craft an interactive drop down menu

Here is the unique HTML code snippet. <dl id="unique-sample" class="unique-dropdown"> <dt><a href="#"></a></dt> <dd> <ul> <li><a href="#">Info</a></li> <li><a h ...

JQuery cannot target content that is dynamically inserted through an Ajax request

When I use an ajax call to pass dynamically generated html, such as in the example below: var loadContent = function(){ $.ajax({ url: '/url', method: 'GET' }).success(function (html) { $('.con ...

What is the correct way to utilize window.scrollY effectively in my code?

Is it possible to have a fixed header that only appears when the user scrolls up, instead of being fixed at the top by default? I've tried using the "fixed" property but it ends up blocking the white stick at the top. Adjusting the z-index doesn&apos ...

Troubleshooting LocalReport Render Errors When Loading Photos Taken with Nikon Coolpix 5600

My RDLC has an embedded image from a Nikon Coolpix 5600 that is causing an error when I call the Render function. Example image: (Page Not Found) Does anyone know what's wrong with this image? The Error: [ArgumentOutOfRangeException: Non-nega ...

Embracing JQuery for Frontend Development with Node.js

I'm currently enhancing my node.js skills by utilizing express, and I've encountered a situation that is causing me some confusion. Essentially, when a user requests a webpage and the backend sends them the HTML page, how can I incorporate a Java ...

Creating a secure webpage that can only be accessed with a password

Is there a way to create a username/password login page using only client-side technologies without involving the server? Back in school, I was taught to use SQL and Java on the server side for this purpose. However, I'm now faced with a situation whe ...

The iPad1 is having trouble displaying the background image, while the iPad2 is showing it perfectly

I am experiencing issues with the background image on my website not displaying properly on an iPad 1, however it appears fine on an iPad 2. Does anyone have any suggestions or ideas on how to fix this? Thank you in advance. ...

Button not displaying box-shadow or drop-shadow effects

Why isn't the filter and box-shadow working on the button? What could be causing this issue and how can it be resolved? .desktop-modal-close-btn { position: absolute; top: 1.5rem; right: 1.5rem; height: 2.8rem; width: 2.8rem; ...

Craft One-Page Online Platforms

Many people have mentioned that frameworks like Bootstrap and Angular are great for creating single-page websites. But why limit them to just that? It seems like they could be just as effective for building multi-page websites as well. ...

How can I utilize CSS to dictate color schemes on an HTML5 canvas element?

Currently, I am working on a checkers project where the first step is to create the initial board. The way we are currently implementing this has raised a philosophical concern. We are using the fillRect function to define the color of the "dark" squares a ...

Creating a nested JSON structure by fetching data from a remote source

i'm looking to populate the json file located at through a get request. This json contains music from various churches in different cities, with data organized into multiple levels. I want to parse this data using jquery and utilize hidden div elemen ...

Is there a way to turn off predictive text for reCAPTCHA on my mobile device?

Using reCAPTCHA on a sign-up form can get frustrating on mobile devices, with constant dictionary word suggestions while typing. I am aware of how to disable this feature for normal input fields by adding attributes through JavaScript, but shouldn't ...

What is the process for importing Gwt-Bootstrap?

I decided to incorporate Gwt-Bootstrap into my UiBinder files. I made sure to import the following: xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"> in my UiBinder file and also added: <script src="http://html5shim.googlecode.c ...

What is the best way to convert minutes into both hours and seconds using javascript?

In order to achieve this functionality, I am trying to implement a pop-up text box where the user can choose either h for hours or s for seconds. Once they make their selection, another pop-up will display the answer. However, I am facing issues with gett ...

Everything seems to be functioning properly on the local server, but once the media files or players (mp3 and mp4) are uploaded, the background fails to work entirely

function playMusic() { var songs = [ "pump.mp3", "ybwm.mp3", "bb.mp3", ]; var randomIndex = Math.floor(Math.random() * songs.length); var selectedSong = songs[randomIndex]; var audio = new Audio(selecte ...

Tips for arranging links in a vertical layout on a navigation bar that is compatible with every device

I'm having trouble aligning the links vertically in the center of the navigation bar, with the logo overlapping the content. Check out the HTML code below: <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

Refreshing the database with new information from an HTML table

Presented below is a table structure: <table id="skuTable" role="grid"> <thead> <th class="skuRow">Order</th> <th class="skuRow">Machine</th> <th>Fab. Date</th> <th cl ...

Enhance your message inbox experience with jQuery/Javascript features inspired by Gmail, including the ability to select all messages with a checkbox and

It is truly satisfying to be here working on developing a private message inbox for my website, especially after successfully implementing a complete user signup/login and activation system. A few months ago, I never believed I had enough patience to grasp ...

tips for showing inlinesvg in internet explorer 8

Can anyone assist me with displaying inlinesvg polygons with links in IE8? Is there a jQuery script or any other solution available? <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width= ...

I'm having trouble modifying the backdrop to 'true' or removing it after setting it to 'static' in Bootstrap. Can anyone help me troubleshoot this issue?

I have been encountering an issue with changing the backdrop setting from 'static' to 'true' in Bootstrap modal. Here is the code I am using: $('#modal').modal({backdrop: 'static', keyboard: false, show: true}); ...