Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display <figure> images on same line HTML/CSS

Tags:

inline

figure

I have 4 images within elements with captions within elements.

Each image is displayed under each other like:

IMAGE
caption

IMAGE
caption

IMAGE
caption

IMAGE
caption

I would like the images to appear like:

IMAGE IMAGE IMAGE IMAGE
caption caption caption caption

My HTML:

<div id="earlylife_images">
            <figure>
                <img src="images/early/moore01.jpg" alt="Roger Moore Teenage" width="150" height="150">
                <figcaption>A young Roger Moore</figcaption>
            </figure>

            <figure>
                <img src="images/early/moore02.jpg" alt="Roger Moore 30's" width="150" height="150">
                <figcaption>Roger Moore in his 30's</figcaption>                    
            </figure>

            <figure>
                <img src="images/early/moore03.jpg" alt="Roger Moore as James Bond" width="150" height="150">
                <figcaption>Roger Moore as James Bond</figcaption>
            </figure>

            <figure>
                <img src="images/early/moore04.jpg" alt="Roger Moore Recent" width="150" height="150">
                <figcaption>Roger Moore in more recent years</figcaption>               
            </figure>

            </div>  
like image 815
markthornton90 Avatar asked Apr 14 '14 15:04

markthornton90


People also ask

How do I make an image appear on one line in HTML?

You have the images enclosed within div tags, which are block elements. You should instead apply the style directly to the images, and do away with the divs, like this: <img style="max-width:20%" src="…"> Save this answer.

How do you put two pictures on the same line in HTML?

Just add a class with inline-block and that will do the trick.

How do you align a figure in CSS?

We can use the float property and text-align property for the alignment of images. If the image is in the div element, then we can use the text-align property for aligning the image in the div.


1 Answers

I was thinking about:

figure {
    width: 25%;
    float: left;
    margin: 0;
    text-align: center;
    padding: 0;
}

You can check it here: http://jsfiddle.net/cBkTc/3/

like image 139
Gogutz Avatar answered Nov 04 '22 11:11

Gogutz