Tips for Aligning Several Images Horizontally in an Article

Does anyone know how to center pictures in an article horizontally? I've tried various techniques without success.

If it would be helpful, I can share the CSS I currently have. However, I am open to starting from scratch with the CSS as well since I am working from a Dreamweaver template.

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

<article class="fluid gallery">
<h2 class="fluid showAreaH2 headingStyle">Edutech Personal del Portador</h2>
<figure class="fluid tiles zeroMargin_desktop zeroMargin_tablet"> <img src="images/mauricio.jpg" alt="Maricio"/>
  <figcaption class="textStyle">Mauricio y Rosalía Sánchez</figcaption>
</figure>
<figure class="fluid tiles"> <img src="images/guillermo.jpg" alt="Guillermo y Sarit"/>
  <figcaption class="textStyle">Guillermo y Sarit Llanos</figcaption>
</figure>

Answer №1

section.media-responsive.gallery {
  align-content: center;
}

Answer №2

Flexbox is a great solution when you need to center content horizontally. Just set the display property to flex, and use justify-content:center. Keep in mind that older browsers may require vendor prefixes.

section {
  width:100%;
  display:flex;
  justify-content:center;
}
img {
  padding:1em;
}
<section>
  <img src="http://placehold.it/50x50">
  <img src="http://placehold.it/50x50">
</section>

Answer №3

To ensure that your pictures are centered within a document, you can enclose them in a specific div like this:

<div class="image-container">
   <img src="..." alt="...">
   ...
</div>

Don't forget to apply the following CSS to style the image container:

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

This way, you can easily align your images with the rest of the content on your page.

Answer №4

If you're looking to horizontally center images on your website, here's a suggestion that might help. It shouldn't be too difficult to implement.

My advice would be to create a container element for the images you want to center horizontally. Then, set those images or their container elements to have a display: inline-block; style.

.gallery {
  text-align: center;
}
.img-container {
  display: inline-block;
}
<div class="gallery">
  <div class="img-container">
    <img src="http://placehold.it/100x50">
    <p>
      Caption
    </p>
  </div>
  <div class="img-container">
    <img src="http://placehold.it/100x50">
    <p>
      Caption
    </p>
  </div>
  <div class="img-container">
    <img src="http://placehold.it/100x50">
    <p>
      Caption
    </p>
  </div>
</div>

Check out the demo on JSFiddle.

Answer №5

(Revised response)

Enclose both pictures in a container and align the content within it:

<article class="fluid gallery">
    <h2 class="fluid showAreaH2 headingStyle">Edutech Personal del Portador</h2>
    <div class="wrapper1">
      <figure class="fluid tiles zeroMargin_desktop zeroMargin_tablet"> <img src="images/mauricio.jpg" alt="Maricio"/>
        <figcaption class="textStyle">Mauricio y Rosalía Sánchez</figcaption>
      </figure>
      <figure class="fluid tiles"> <img src="images/guillermo.jpg" alt="Guillermo y Sarit"/>
        <figcaption class="textStyle">Guillermo y Sarit Llanos</figcaption>
      </figure>
    </div>
    <!-- additional text? -->
</article>

CSS:

.wrapper1 {
  width: 100%;
  text-align: center;
}

Answer №6

I concur with Arathi Sreekumar's suggestion. In addition, it is important to include the following CSS code:

.figure-wrapper figure { display: inline-block; }

You may also consider including padding for the .figure-wrapper figure element.

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

How can I retrieve the HTML content of a ReactJS rectangle element saved in an array?

Within a loop, I am creating rectangle elements and adding them to an array: rectangles = []; render: function() { for (var i = 0 ; i < 10; i++) { rectangles.push (<Rectangle height={this.props.afm} width={this.props.afm} x={xpos} y={ypos} va ...

What steps can I take to stop my browser from displaying the "waiting for MyHostName" message while performing an ajax Post/Get operation?

Whenever I access a website using Chrome, a message appears in the status bar saying "Waiting for MyHost name" along with an Ajax Loader circle in the browser tab. Here is a javascript function that I am working with: function listen_backend_client_reques ...

Creating consistently sized rows of Bootstrap columns - with either equal heights or equal spacing between each row

It would be great if bootstrap had a built-in feature where it automatically assigns the wrapper div of any item with a height based on the height of the largest div. In this example on JSFiddle, you can see that I have different heights for the video-ite ...

Exploring scraping capabilities in Node.js

Currently, I am in the process of developing a scraping engine using Node.js to collect data for my currency exchange graphs. I am utilizing request and cheerio for this task. However, due to some bank websites not following standard HTML practices by not ...

Arranging arrows strategically along a line and ensuring they are positioned correctly above all div elements

I'm really struggling with this issue. I have a situation where I need to center a downward pointing arrow within some divs. It should be positioned in the middle, on a brown line, and on top of everything else. The last div should also include the a ...

What is the best way to arrange these badges in a row?

I'm struggling to horizontally align these badges next to each other, as inline-block isn't working and they keep stacking vertically instead of side by side. How can I achieve the alignment shown in the image below? This is the desired appeara ...

Is it possible that the Divi blurb module fails to extend to the full height of the row?

I frequently use Divi blurb modules, as seen here: - positioned at the top of the page, just below the header. However, I am facing an issue with getting them to be consistent in height. The 'database generation' module appears shorter than the ...

Challenge in creating a responsive layout using Bootstrap framework

I'm working with Bootstrap, but I'm struggling to achieve the desired layout. My goal is to have the design adapt like this on different screen sizes: ---------------------- Headline | | | image | ----------| | B ...

When the click event occurs, add a class. After a delay using a timeout function, remove the added

I am currently using Jimdo and I have a section where I can edit all the codes, which is working fine except for one feature. Any assistance would be greatly appreciated! Here is the code that adds a class to an animated SVG image with its status set as d ...

Achieve the effect of "background-attachment: fixed" using a div element

I am attempting to replicate a similar effect as seen here, which is accomplished using the CSS property background-attachment:fixed. However, I want to achieve this effect using div elements instead. For instance, could I apply this effect to an h1 tag? ...

Convert HTML content to a PDF file with Java

Welcome to the community! My project involves extracting data from a website containing information on various chemical substances and converting it into a PDF while preserving the original HTML formatting, including CSS styles. For example, here is a li ...

Adding a div beside an input element - step by step guide

When creating an input field in my code, I followed these steps: var inputVal = document.createElement("input"); inputVal.setAttribute("type", "checkbox"); inputChek.onchange = select; inputChek.setAttribute("value", title); //inputChek.after(sortDiv); ...

Tips for retrieving user input and displaying it on an HTML page

I have encountered an issue with displaying user input in a table. The code for the table display is as follows: <tr ng-repeat="user in users" ng-class-even="'bg-light-grey'" ng-if="isLoading==false"> <td> ...

Is your Z-Index failing to make an impact?

Currently, I am attempting to layer divs on top of a background image. All the elements have designated position attributes, and I have applied a 50% opacity to the background image so that what's behind it is partially visible. Despite setting the z- ...

Convert text to bold when checkbox is selected and alter color upon selecting a radio button

Having just started learning HTML, CSS, and PHP, I find myself in need of assistance. Despite extensive research online, I have hit a dead end and cannot seem to find any productive solutions. Any guidance or suggestions would be greatly appreciated! I am ...

(Original) redirect from specific url / url detection New text: "Redirection

Sorry for the long and confusing question, my apologies for wasting your time. I am still learning programming and what I really wanted to ask is "how can I retrieve a GET parameter using JavaScript?" Apologies for any inconvenience. ...

Progressive computation depending on the size of the window in Cascading Style Sheets

Is there a way to dynamically calculate the left percentage in CSS based on the window width? For example: if width > 700px: left: 30% if width > 800px: left: 32% Any suggestions on how to achieve this effect? ...

Customizing Semantic UI Navigation Menu Styles

For the first time, I am incorporating semantic-ui into my React application. The specific package I am working with can be found here: To display my header, I am using the following code: <Menu className='header' > <Containe ...

Cursor hovers over button, positioned perfectly in the center

I am facing a challenge with implementing a hover function for a set of buttons on the screen. The goal is to display the mouse pointer at the center of the button upon hovering, rather than the actual position of the cursor being displayed. I have tried u ...

Generate Material UI sidebar components that are positioned above all other components

I am currently working on a sidebar component using the Material UI Drawer component. I am looking to add components that align side by side with the sidebar, similar to the green box shown in the image below. After attempting to code this, I ended up wi ...