<figure>
<img src="imgsrc1.png" alt="image">
<figcaption>Caption</figcaption>
<img src="imgsrc2.png" alt="image">
<figcaption>Caption</figcaption>
<img src="imgsrc3.png" alt="image">
<figcaption>Caption</figcaption>
</figure>
<!--As you can see it makes the images aligned Vertically--!>
I have been attempting to have a part of my website where I have three images horizontally aligned with captions. I have decided to use the figure tag which has them horizontally aligned, however, when I add a figcaption they become vertically aligned (stacked on top of each other). This is not what I want and I don't understand why the figcaption does this. Can anyone tell me how to keep the images horizontally aligned?
Related
I doesn't know how to achieve the following. I have a section that holds 3 images. Those images will be responsive in that section. I would like to align the holder div to the left side of the viewport and the right side of the holder div to the container div. See image:
My markup looks like the following:
<section>
<figure>
<img src="http://placehold.it/400x210">
</figure>
<figure>
<img src="http://placehold.it/400x210">
</figure>
<figure>
<img src="http://placehold.it/400x210">
</figure>
</section>
Is this possible with css only?
CodePen: https://codepen.io/anon/pen/bWWyJN
Have you tried using flexboxes? Put display: flex; flex-direction: row; on your container and flex: 1 1 auto; on your children. (That should be a simple enough case for IE to get it right. :)
I'm currently trying to design a web page. I don't have much experience with HTML and are therefore finding it difficult to get my page looking how i'd planned. I would like to have four square images, two top with two directly below but im struggling to align these. I've tried to research this but all i seem to be able to find are examples with text wrap.
any help appreciated, thanks.
Are your images of the same size ?
Without more information on what you want/have on your page, it's kind of hard to know what you need.
But here's an simple example : http://codepen.io/cecileledoux/pen/mWJyGV
<section>
<figure>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Solid_blue.svg/225px-Solid_blue.svg.png" alt="" />
</figure>
<figure>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Solid_blue.svg/225px-Solid_blue.svg.png" alt="" />
</figure>
</section>
<section>
<figure>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Solid_blue.svg/225px-Solid_blue.svg.png" alt="" />
</figure>
<figure>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Solid_blue.svg/225px-Solid_blue.svg.png" alt="" />
</figure>
</section>
section{
margin-bottom: 20px;
text-align: center;
}
figure{
display: inline-block;
}
I would like to know if a figure element can contain more than one figcaption child?
I read something somewhere (sorry, now I can't find it) that seemed to suggest it couldn't- yet I am sure that a figure can contain more than one img, so that seems illogical.
What if I have two related images side by side, for which I want separate captions?
You can nest the img plus its figcaption into multiple figure tags. To add more semantics to the code you can add an ARIA role attribute.
<figure role="group">
<figcaption>Caption for the whole group of images</figcaption>
<figure>
<img src="picture1.jpg" alt="Description of picture 1">
<figcaption>Caption for Picture 1</figcaption>
</figure>
<figure>
<img src="picture2.jpg" alt="Description of picture 2">
<figcaption>Caption for Picture 2</figcaption>
</figure>
</figure>
In HTML5 figure is a sectioning root. It may have sectioning root or flow content as content. A figcaption is flow content, and may only have flow content as content. So, a figcaption may not have a figure as content.
A figure may have another figure as content, however. Keep in mind that a figcaption must be the first or last child of a figure.
So code might look like this:
<figure>
<img>
<figure>
<figcaption></figcaption>
</figure>
<figcaption></figcaption>
</figure>
or
<figure>
<figcaption></figcaption>
<img>
<figure>
<figcaption></figcaption>
</figure>
</figure>
See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure
and https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure
For what I can see, you can only use it once within figure: http://www.w3schools.com/tags/tag_figcaption.asp
so I'm trying to position my content box and its working fine for left, but when I try change the right value it doesn't allow. As you can see I have four images, but I want to show three, so therefore I'm trying to increase the right value so the box can only fit three (and also bring it in to the center a bit more)
I can get it to work by changing it to padding-right instead of right, but I don't understand why that works? My understanding is that : Padding = Distance between the content and the border, and right = how far from the edge?
Image:
This is my content box code (the images are inside it in another box)
.imagesArea {
position:relative;
top:15px;
left:100px;
padding-right:180px;
}
Thanks
edit: html (removed some of the image code)
<div class="imagesArea">
<div class="images">
<figure>
<img src="photos/image1.jpg" alt=”Photo” width=150 height=150>
<figcaption>Watch #1</figcaption>
</figure>
</div>
<div class="images">
<figure>
<img src="photos/image2.jpg" alt=”Photo” width=150 height=150>
<figcaption>Watch #2</figcaption>
</figure>
</div>
<div class="images">
<figure>
<img src="photos/image3.jpg" alt="Photo" width="150" height="150">
<figcaption>watch #3</figcaption>
</figure>
</div>
</div>
Your understanding of relative positioning is completely wrong. It sounds like you are confusing it with margins.
With relative positioning, the element is sized and positioned according to normal flow (i.e. as if it was statically positioned), and then the whole box is offset according to left/right/etc. This can cause it to overlap with other elements.
See this example for a visual representation.
It won't adjust the size of the box at all, so it will have no influence over how much content it can hold.
If you want to control how wide the element is, use width, padding, border and/or margin.
You can use margin for inner content div images
.images{
display: inline-block;
margin:0 20px 0 20px;
}
and set parent div
.imagesArea {
position:relative;
top:15px;
left:100px;
padding-right:180px;
text_align:center;
}
As you want to show 3 images in a row, It will work for you.
How do I horizontally center a set of 4 images (one square block) inside a parent div with CSS? I also need the image block to occupy 100% of the screen vertically.
Thanks.
<div id="outer" style="width:100%">
<div id="photoBox" style="inline-block">
<img src="#">
<img src="#">
<img src="#">
<img src="#">
</div>
</div>
You should use
display: inline-block instead of inline-block css stylesheet
Look here