Attempting to align multiple images in the center

I'm struggling with this issue, trying to center my images. It seems like the first image referenced in imgTop is centered while the second one goes to the right. I want both to be centered evenly. Any help would be appreciated!

#imageContainer {
  width: 100%;
  text-align: center;
}
.imgTop {
  display: inline-block;
  margin-left: auto;
  margin-right: auto;
  width: 60px;
  height: 40px;
  padding-left: 85pt;
  padding-right: 85pt;
}
.imgBottom {
  display: inline-block;
  margin-left: auto;
  margin-right: auto;
  width: 60px;
  height: 40px;
  padding-left: 85pt;
  padding-right: 85pt;
}
<div id="imageContainer">
  <div class="imgTop">
    <a class="imageSlot">
      <img src="src/gameImages/img3.jpg">
    </a>
  </div>
  <div class="imgTop">
    <a class="imageSlot">
      <img src="src/gameImages/img4.jpg">
    </a>
  </div>
</div>

<div id="imageContainer">
  <div class="imgBottom">
    <a class="imageSlot">
      <img src="src/gameImages/img4.jpg">
    </a>
  </div>
  <div class="imgBottom">
    <a class="imageSlot">
      <img src="src/gameImages/img3.jpg">
    </a>
  </div>
</div>

Answer №1

Not entirely sure if I understood correctly... but you're looking to have both pictures centered rather than just one? What I did was combine the two images into one div tag and position them together.

<div id="imageContainer">
        <div class="imgTop">
            <a class="imageSlot"><img src="http://zoarchurch.co.uk/content/pages/uploaded_images/91.png"></a>
            <a class="imageSlot"><img src="http://zoarchurch.co.uk/content/pages/uploaded_images/91.png"></a>
        </div>
    </div>

    <div id="imageContainer">
        <div class="imgBottom">
            <a class="imageSlot"><img src="http://zoarchurch.co.uk/content/pages/uploaded_images/91.png"></a>
            <a class="imageSlot"><img src="http://zoarchurch.co.uk/content/pages/uploaded_images/91.png"></a>
        </div>
    </div>

Check out my fiddle for a visual: https://jsfiddle.net/gswq55x2/

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

Having trouble with the collapse feature on my DataList cards

I have a sample card and a DataList on my webpage. The collapse functionality is functioning correctly on the example card, but I am unable to get it to work on the actual cards. Below is the code snippet for reference: <div class="resultadosEspe ...

What are some strategies for accessing the original values of form components that have not been altered when using ngModel?

I am currently developing a form and I intend to utilize the previous values as "value" in the form. By employing ngModel dynamically, I am able to change some properties. However, I have encountered an issue where the field that remains unchanged by the u ...

The showdown between AngularJS Directive Restrict A and E

In our small team, we are currently working on a project in AngularJS and striving to uphold basic standards and best practices. Since we are still relatively new to Angular, we have some questions regarding Directives, specifically the `restrict` options. ...

Adjustable Bootstrap Progress Bar - Modify element width on the fly

I have encountered an issue with my progress bars on the webpage. The static HTML version works perfectly fine, but the dynamically created one using jQuery seems to be instantly at 100% without any delay in progression. To illustrate the problem better, ...

Converting CSS to LESS with multiple classes sharing the same properties: step-by-step guide

I have some CSS code here that I'd like to convert into LESS format. Can you help me with that? .A .B h4, .A .B h4 a, .A .C h4, .A .C h4 a, .D h4, .D h4 a { color: #345e8a !important; display: inline-block; font-family: @font-family-sans ...

Encountering difficulties with the mobile display of a Wordpress theme

I am currently working with the megashop theme on WordPress and I have a few queries that need addressing: Is there a way to modify a specific setting exclusively for views smaller than desktop size, without impacting the desktop view? For example, the m ...

How to create a vertically scrollable div within another div by utilizing scrollTop in jQuery

I need assistance with scrolling the #container div inside the .bloc_1_medias div. The height of #container is greater than that of .bloc_1_medias. My goal is to implement a function where clicking on the "next" and "previous" text will scroll the #contai ...

Tips for designing a button that can execute a JavaScript function repeatedly

My goal is to rotate the numbers clockwise when the rotate button is clicked. I have included all the relevant code. I have created a button that triggers a javascript function when clicked. The problem is that the function only rotates the numbers once. ...

Creating a pull-up toolbar with just HTML and CSS for an Android browser

I need to create a draggable toolbar on my mobile webapp that can reveal content beneath it. I want to achieve this using just HTML/CSS, without relying on touch/scroll events or libraries. To do this, I'm overlaying a scrolling element on top of the ...

CSS - Ensuring that the height of one div extends all the way down to meet another div

I'm facing an issue with two divs in my design. One of them contains a checkbox and the other has text which can vary in size - sometimes it's small, sometimes it's large. When the text in the second div is big, the box on the left extends a ...

Issues with concealing the side menu bar in Vue.js

I've been attempting to conceal the side menu bar, with the exception of the hamburger icon when in the "expanded" state. Despite my efforts to modify the CSS code, I am still struggling to hide the small side menu bar. The following images represent ...

Developing a custom styling class using JavaScript

Looking to create a custom style class within JavaScript tags. The class would look something like this: #file-ok { background-image: url(<?php echo json.get('filename'); ?>); } Essentially, the value returned from the PHP file (json ...

Missing Home and Search icons on Jquery mobileNavigationBar

I am having an issue where the Home and search icons are not displaying properly in the output. Instead, they are showing up as hyperlinks. Can someone please help me with this? Here is the code I am using: <meta name="viewport" content="width=device ...

Add() function is not duplicating the formatting

I'm attempting to replicate the content below inside a DIV. <ul class="pie-legend"><li><span style="background-color:#0066CC"></span>10-0-1</li><li><span style="background-color:#33CC33&q ...

White space in Bootstrap 4 grid caused by a full-width row

I have set up a bootstrap grid layout that includes ads, and I wanted to integrate a section for banners within it. After some experimentation, I managed to achieve this by inserting a container between the ads and the banners, each housed in their own row ...

The bootstrap 4 dropdown button fails to activate the dropdown feature

I am currently working on a Flask application with Bootstrap integration. I am facing an issue while trying to incorporate a dropdown menu, which needs jQuery + Popper elements in order to work properly. Even though the button is displayed, the dropdown fu ...

The pseudo right arrow is failing to display in the vertical center

My pseudo right arrow is not displaying vertically centered within the .nav-link class. Can anyone suggest how I can achieve vertical alignment for my right arrow in an <a> tag? I have already attempted using top:50% but it did not work. Here is th ...

Printing a React component using a button causes formatting related to className to be lost, while printing it inline preserves the formatting

I've hit a roadblock in trying to figure out the React and printing issue for the past week and a half, and it feels like I'm going in circles. Despite finding some helpful solutions on Stack Overflow, none of them seem to work completely for me ...

Something seems off with Chrome

I am facing a unique issue that I need help with. Unfortunately, the code is too long to post here but essentially it involves creating a menu for a website. The menu works perfectly and looks great on all browsers except for Chrome. This is unusual as Ch ...

Finding the Closest Element with jQuery's .closest() Method

I'm facing an issue while trying to select an element that is positioned above another element. Specifically, I want to target the nearest occurrence of the .discount-dropdown class that appears above the .discount-type class. Can anyone help me figur ...