How to align a flex item when it's very long - html

I'm creating a very simple responsive image gallery, with the least amount of css posible.
I've came up with the following
<div class="container">
<ul class="thumbnail">
<li>
<div>
<img class="fluid" src="" width="" height="" alt="">
</div>
<div class="thumb-caption">
<p>name goes here</p>
<p>subname goes here</p>
<p>year</p>
<img src="" width="20" height="15" alt="">
</div>
</li>
...
</ul>
</div>
CSS:
.thumbnail {
display: flex;
flex-wrap: wrap;
margin: -20px 0 0 -20px;
}
.thumbnail li {
margin: 20px 0 0 20px;
}
.thumbnail img {
display: block; /* remove bottom gap */
}
.thumb-caption {
display: flex;
flex-direction: column;
align-items: center;
}
.thumb-caption > * {
margin-top: 10px;
}
... and the result
https://jsfiddle.net/51yrdk11/
I want to center everything inside the class thumb-caption. It could be a <p> or img tag.
For some reason, when one of the <p> in the thumb-caption class is very long, it does not center correctly.
Can anybody tell me why and to fix it?
EDIT
I know that by using text-align:center an the <p> tags, it aligns correctly. But, why? Why some are align and the long ones are not align? I need to understand the logic.

The align-items is used to align the flex-items. It will not align the inner content of the flex-items.
You have to use text-align: center in the .thumb-caption class
Stack Snippet
/*----- reset -----*/
* {
box-sizing: border-box;
}
p,
ul,
ol {
list-style: none;
margin: 0;
padding: 0;
}
/* end - reset */
.container {
max-width: 800px;
margin: auto;
background-color: pink;
}
.thumbnail {
display: flex;
flex-wrap: wrap;
margin: -20px 0 0 -20px;
}
.thumbnail li {
margin: 20px 0 0 20px;
}
.thumbnail img {
display: block;
/* remove bottom gap */
}
.thumb-caption {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}
.thumb-caption>* {
margin-top: 10px;
}
/* media queries */
.thumbnail li {
flex-basis: calc((100% / 3) - 20px);
}
/* end- media queries */
.fluid {
max-width: 100%;
height: auto;
}
<div class="container">
<ul class="thumbnail">
<li>
<div>
<img class="fluid" src="http://via.placeholder.com/400x400" width="" height="" alt="">
</div>
<div class="thumb-caption">
<p>
name goes here
</p>
<p>
subname goes here
</p>
<p>
year
</p>
<img src="http://via.placeholder.com/20x15" width="20" height="15" alt="">
</div>
</li>
<li>
<div>
<img class="fluid" src="http://via.placeholder.com/400x400" width="" height="" alt="">
</div>
<div class="thumb-caption">
<p>
name goes here
</p>
<p>
subname is very very long, and when it is very long, for some reason, it does not center correctly, why?
</p>
<p>
year
</p>
<img src="http://via.placeholder.com/20x15" width="20" height="15" alt="">
</div>
</li>
<li>
<div>
<img class="fluid" src="http://via.placeholder.com/400x400" width="" height="" alt="">
</div>
<div class="thumb-caption">
<p>
name goes here
</p>
<p>
subname goes here
</p>
<p>
year
</p>
<img src="http://via.placeholder.com/20x15" width="20" height="15" alt="">
</div>
</li>
<li>
<div>
<img class="fluid" src="http://via.placeholder.com/400x400" width="" height="" alt="">
</div>
<div class="thumb-caption">
<p>
name goes here
</p>
<p>
subname goes here
</p>
<p>
year
</p>
<img src="http://via.placeholder.com/20x15" width="20" height="15" alt="">
</div>
</li>
<li>
<div>
<img class="fluid" src="http://via.placeholder.com/400x400" width="" height="" alt="">
</div>
<div class="thumb-caption">
<p>
name goes here
</p>
<p>
subname goes here
</p>
<p>
year
</p>
<img src="http://via.placeholder.com/20x15" width="20" height="15" alt="">
</div>
</li>
</ul>
</div>
Updated Fiddle

The reason the smaller text is centered and the long is not, is because it is the p element that gets centered, not its content.
What the align-items: center does is making the p shrink to its content, in opposite to its default, stretch, which makes it fill its parent's width, hence when content is too wide it can't center the p anymore, as it takes full width.
As you already know, text-align: center targeting the p element will fix this.
As a note, one of the simplest things one can do, to understand these kind of logics, is to add a border or background color on the element that seems to behave odd, in this case on the p, and one will most of the time see what's going on.
/*----- reset -----*/
* {
box-sizing: border-box;
}
p,
ul,
ol {
list-style: none;
margin: 0;
padding: 0;
}
/* end - reset */
.container {
max-width: 800px;
margin: auto;
background-color: pink;
}
.thumbnail {
display: flex;
flex-wrap: wrap;
margin: -20px 0 0 -20px;
}
.thumbnail li {
margin: 20px 0 0 20px;
}
.thumbnail img {
display: block; /* remove bottom gap */
}
.thumb-caption {
display: flex;
flex-direction: column;
align-items: center;
}
/* for this demo */
.thumb-caption p {
border: 1px dashed black;
}
.thumb-caption > * {
margin-top: 10px;
}
/* media queries */
.thumbnail li {
flex-basis: calc((100% / 3) - 20px);
}
/* end- media queries */
.fluid {
max-width: 100%;
height: auto;
}
<div class="container">
<ul class="thumbnail">
<li>
<div>
<img class="fluid" src="http://via.placeholder.com/400x400" width="" height="" alt="">
</div>
<div class="thumb-caption">
<p>
name goes here
</p>
<p>
subname goes here
</p>
<p>
year
</p>
<img src="http://via.placeholder.com/20x15" width="20" height="15" alt="">
</div>
</li>
<li>
<div>
<img class="fluid" src="http://via.placeholder.com/400x400" width="" height="" alt="">
</div>
<div class="thumb-caption">
<p>
name goes here
</p>
<p>
subname is very very long, and when it is very long, for some reason, it does not center correctly, why?
</p>
<p>
year
</p>
<img src="http://via.placeholder.com/20x15" width="20" height="15" alt="">
</div>
</li>
<li>
<div>
<img class="fluid" src="http://via.placeholder.com/400x400" width="" height="" alt="">
</div>
<div class="thumb-caption">
<p>
name goes here
</p>
<p>
subname goes here
</p>
<p>
year
</p>
<img src="http://via.placeholder.com/20x15" width="20" height="15" alt="">
</div>
</li>
<li>
<div>
<img class="fluid" src="http://via.placeholder.com/400x400" width="" height="" alt="">
</div>
<div class="thumb-caption">
<p>
name goes here
</p>
<p>
subname goes here
</p>
<p>
year
</p>
<img src="http://via.placeholder.com/20x15" width="20" height="15" alt="">
</div>
</li>
<li>
<div>
<img class="fluid" src="http://via.placeholder.com/400x400" width="" height="" alt="">
</div>
<div class="thumb-caption">
<p>
name goes here
</p>
<p>
subname goes here
</p>
<p>
year
</p>
<img src="http://via.placeholder.com/20x15" width="20" height="15" alt="">
</div>
</li>
</ul>
</div>

Related

How can we target the right most Child of Parent

I have a parent container 'Streams' and it's Childs 'course' i what to set the margin-right: 10px to every child except the child appear at the rightmost of a parent
if I use '.course:nth-child(3n)' it works fine until the browser window is full when we zoom the page or window size change it didn't work properly.
.Streams {
width: 100%;
height: auto;
padding: 40px 60px 40px 60px;
display: flex;
flex-wrap: wrap;
}
.course {
width: 300px;
border: 1px solid black;
margin-right: 10px;
}
<div class="Streams">
<div class="course">
<img src="#" alt="BCA" />
<p>
div 1
</p>
</div>
<div class="course">
<img src="#" alt="BCA" />
<p>
div 2
</p>
</div>
<div class="course">
<img src="#" alt="BCA" />
<p>
div 3
</p>
</div>
<div class="course">
<img src="#" alt="BCA" />
<p>
div 4
</p>
</div>
<div class="course">
<img src="#" alt="BCA" />
<p>
div 4
</p>
</div>
</div>
to Fix this i use but this only effect the very last child.
.course:last-of-type{
margin-right:0px;
}
What you need to do is take a similar approach that Bootstrap does for its column implementations:
.Streams {
padding: 60px -5px;
...
}
.course {
...
margin: 0 5px;
}
If the distance between components you want is Xpx then
The formula is horizontal margin (x/2)px on the children, and horizontal padding -(x/2)px on parent.
.Streams {
width: 100%;
height: auto;
padding: 40px -5px;
display: flex;
flex-wrap: wrap;
}
.course {
width: 300px;
border: 1px solid black;
margin: 0 5px;
}
<div class="Streams">
<div class="course">
<img src="#" alt="BCA" />
<p>
div 1
</p>
</div>
<div class="course">
<img src="#" alt="BCA" />
<p>
div 2
</p>
</div>
<div class="course">
<img src="#" alt="BCA" />
<p>
div 3
</p>
</div>
<div class="course">
<img src="#" alt="BCA" />
<p>
div 4
</p>
</div>
<div class="course">
<img src="#" alt="BCA" />
<p>
div 4
</p>
</div>
</div>
You can use this code in (.course:last-child)
body {
margin: 0;
}
.Streams {
width: 100%;
height: auto;
padding: 40px 60px 40px 60px;
display: flex;
flex-wrap: wrap;
}
.Streams .course {
width: 300px;
border: 1px solid black;
margin-right: 10px;
margin-bottom: 5px;
}
.Streams .course:last-child {
margin-right: 0px;
}
<div class="Streams">
<div class="course">
<img src="#" alt="BCA" />
<p>
div 1
</p>
</div>
<div class="course">
<img src="#" alt="BCA" />
<p>
div 2
</p>
</div>
<div class="course">
<img src="#" alt="BCA" />
<p>
div 3
</p>
</div>
<div class="course">
<img src="#" alt="BCA" />
<p>
div 4
</p>
</div>
<div class="course">
<img src="#" alt="BCA" />
<p>
div 4
</p>
</div>
</div>

3 images centered in a row

I am trying to have three images centered in a row and then centered on the page. I've got them all in a row but I cannot get them centered. Any suggestions on getting my group to the middle? I tried 0 auto on the contain class and on the social class. so close!!
My HTML: first thing is div class=contain to wrap the whole thing, but for some reason if I try to include the class contain in HTML it disppears on Stack Overflow so excuse that.
.contain {
max-width: 960px;
text-align: center;
}
.social {
position: relative;
display: inline-block;
float: left;
padding: 10px;
}
<div class="contain">
<div align="center;" class="social">
<img src="http://theinvicto.com/wp-
content/uploads/2017/12/facebook.png" alt="" width="75" height="75" />
</div>
<div align="center;" class="social">
<img src="http://theinvicto.com/wp-content/uploads/2017/12/twitter.png" alt="" width="75" height="75" />
</div>
<div align="center;" class="social">
<img src="http://theinvicto.com/wp-
content/uploads/2017/12/instagram.png" alt="" width="75" height="75" />
</div>
</div>
What I would recommend is to make use of flexbox container for the elements.
With flexbox, all you need is three different styles in order to centralise elements both horizontally and vertically:
display: flex;
align-items: self;
justify-content: center;
Note that you'll also need to set a height on the container, so that the elements can actually fill the vertical space.
This can be seen in the following, with a border added to showcase the area that the .container element occupies:
.container {
display: flex;
align-items: center;
justify-content: center;
height: 200px;
border: 1px solid black;
}
.social {
position: relative;
display: inline-block;
float: left;
padding: 10px;
}
<div class="container">
<div align="center;" class="social">
<img src="http://theinvicto.com/wp-
content/uploads/2017/12/facebook.png" alt="" width="75" height="75" />
</div>
<div align="center;" class="social">
<img src="http://theinvicto.com/wp-content/uploads/2017/12/twitter.png" alt="" width="75" height="75" />
</div>
<div align="center;" class="social">
<img src="http://theinvicto.com/wp-
content/uploads/2017/12/instagram.png" alt="" width="75" height="75" />
</div>
</div>
Hope this helps! :)
html
<div class="content">
<div>
<img src="facebook.png" alt="" width="75" height="75"/>
</div>
<div>
<img src="twitter.png" alt="" width="75" height="75"/>
</div>
<div>
<img src="instagram.png" alt="" width="75" height="75" />
</div>
</div>
css
.content {
text-align:center;
}
Maybe you can edit the css file, remove the float:left; :
.contain {
max-width:960px;
text-align:center;
}
.social {
position:relative;
display: inline-block;
padding: 10px;
}
<div align="center">
<div align="center;" class="social">
<img src="http://theinvicto.com/wp-
content/uploads/2017/12/facebook.png" alt="" width="75" height="75" />
</div>
<div align="center;" class="social">
<img src="http://theinvicto.com/wp-content/uploads/2017/12/twitter.png"
alt="" width="75" height="75" />
</div>
<div align="center;" class="social">
<img src="http://theinvicto.com/wp-
content/uploads/2017/12/instagram.png" alt="" width="75" height="75" />
</div>
</div>
Using flex is a great solution, but here's a solution that uses what you already have. By removing float: left from your existing code we can get the desired result.
.contain {
max-width: 960px;
text-align: center;
}
.social {
display: inline-block;
padding: 10px;
}
<div class="contain">
<div align="center;" class="social">
<img src="http://theinvicto.com/wp-
content/uploads/2017/12/facebook.png" alt="" width="75" height="75" />
</div>
<div align="center;" class="social">
<img src="http://theinvicto.com/wp-content/uploads/2017/12/twitter.png" alt="" width="75" height="75" />
</div>
<div align="center;" class="social">
<img src="http://theinvicto.com/wp-
content/uploads/2017/12/instagram.png" alt="" width="75" height="75" />
</div>
</div>
Keeping your current code, simply remove the flex: left: (JSFiddle example):
.contain {
max-width: 960px;
text-align: center;
}
.social {
position: relative;
display: inline-block;
padding: 10px;
}
If based on your browser compatibility requirements you can afford to use display: flex; (MDN) then that's the easiest way (jsfiddle example):
.contain {
display: flex;
justify-content: center;
}
.social {
padding: 10px;
}
There's an excellent flexbox tutorial here: flexbox froggy. Floats are pretty strange and I personally find flexes much more intuitive.

Put different paragraphs under 3 images in html5,using a class

I have 3 images
HTML:
<img src="cal.png" alt = "calendar" class="info">
<img src="location.png" alt = "location" class="info">
<img src="time.png" alt = "clock" class="info">
CSS:
.info{
height: 15%;
align-content: center;
padding-left: 20%;
}
Now, I want to add text under the 3 images, the text should be centered. It will be 3 different . The 3 images should be on one line.
Please try this code:
Html:
<div class="div-test">
<img src="invoice_logo.png" alt = "calendar" class="info">
<div >YOUR TEXT</div>
</div>
css:
.info{
height: 15%;
align-content: center;
}
.div-test{text-align:center;}
.div-test > span {clear:both;}
From your class remove margin left.If not required then.
You can use the figcaption tag, which is meant for this exact purpose:
div figure {
display: inline-block;
}
.info {
height: 15%;
text-align: center;
}
<div>
<figure>
<img src="http://via.placeholder.com/150x150" alt="calendar" class="info">
<figcaption class="info">Info about image one.</figcaption>
</figure>
<figure>
<img src="http://via.placeholder.com/150x150" alt="location" class="info">
<figcaption class="info">Info about image two.</figcaption>
</figure>
<figure>
<img src="http://via.placeholder.com/150x150" alt="clock" class="info">
<figcaption class="info">Info about image three.</figcaption>
</figure>
</div>
Your HTML:
<div class="img-with-text">
<img src="yourimage.png" alt="sometext" />
<p>Some text</p>
</div>
Your CSS:
.img-with-text {
text-align: justify;
width: [width of img];
}
.img-with-text img {
display: block;
margin: 0 auto;
}
https://stackoverflow.com/a/1225242/6441416
https://stackoverflow.com/users/7173/jason

Center text underneath images in a row

The text representing each image is currently located to the right of the image. I want the text to be centered underneath its corresponding image, how do I achieve this?
Please note that I applied display: inline-bock on the list items, so they are in a row.
#footer1 {
float: left;
width: 100%;
border: 10px solid #e3e3e3;
}
#footer1>ul>li {
padding: 0 8px;
display: inline-block;
}
#footer1 a:hover img {
border: 1px solid #5cadff;
text-decoration: none;
box-shadow: 5px 5px 2px 2px #5cadff;
}
#footer1 img {
border: 1px solid transparent;
margin-left: 110px;
}
<div id="footer1">
<h2> SOURCES </h2>
<ul>
<li>
<a href="https://www.wikipedea.com" title="wikipedia">
<img height="50" src="http://www.placehold.it/50" width="50">
</a>
w
</li>
<li>
<a href="https://www.google.com" title="google">
<img height="50" src="http://www.placehold.it/50" width="50">
</a>
Google
</li>
<li>
<a href="https://www.youtube.com" title="youtube">
<img height="50" src="http://www.placehold.it/50" width="50">
</a>
Youtube
</li>
<li>
<a href="https://www.nlm.nih.gov/" title="Nih.gov">
<img height="50" src="http://www.placehold.it/50" width="50">
</a>
Nih
</li>
<li>
<a href="https://www.medindia.net" title="MedIndia.net">
<img height="50" src="http://www.placehold.it/50" width="50">
</a>
MedIndia
</li>
</ul>
</div>
I was able to do this without any changes to your existing HTML by doing this:
li{
display:inline-block;
text-align:center;
width:70px;
}
li img{
margin:0 10px;
}
The text-align centers all text and child elements inside the li. The width needs to be large enough that no caption will be too large to fit in that width. (If a caption won't fit in the allotted width, then the centering is wrecked.)
I added the left and right margin to the image for a little bit of future-proofing in case you later want to include a very short caption in your list. With that margin, even a very short caption will be forced to the next line (instead of next to the image) since 50 px image width + 10 margin on each side leaves no room for text.
Edited for float, keeps these inline and overflows if doesn't fit on page.
<style>
.container {
clear: both;
}
ul li {
width: 50px;
float: left;
text-align: center
}
ul li a {
text-decoration: none;
}
</style>
<div class="container">
<ul>
<li>
<a title="wikipedia" href="https://www.wikipedea.com">
<img src="wikipedia.png" height="50" width="50">wikipedia
</a>
</li>
<li>
<a title="wikipedia" href="https://www.wikipedea.com">
<img src="wikipedia.png" height="50" width="50">wikipedia
</a>
</li>
<li>
<a title="wikipedia" href="https://www.wikipedea.com">
<img src="wikipedia.png" height="50" width="50">wikipedia
</a>
</li>
</ul>
</div>
Please try this
HTML:
<div id="footer1">
<h2> SOURCES </h2>
<div class="item">
<a title="wikipedia" href="https://www.wikipedea.com">
<img src=""/>
</a>
<span class="caption">Text below the image</span>
</div>
<div class="item">
<a title="wikipedia" href="https://www.wikipedea.com">
<img src=""/>
</a>
<span class="caption">Text below the image</span>
</div>
<div class="item">
<a title="wikipedia" href="https://www.wikipedea.com">
<img src=""/>
</a>
<span class="caption">Text below the image</span>
</div>
</div>
CSS:
div.item {
vertical-align: top;
display: inline-block;
text-align: center;
width: 120px;
}
img {
width: 100px;
height: 100px;
background-color: grey;
}
.caption {
display: block;
}
DEMO

How to align text below an image in CSS?

HTML
<div class="image1">
<img src="images/img1.png" width="250" height="444" alt="Screen 1"/>
<img src="images/img2.png" width="250" height="444" alt="Screen 2"/>
<img src="../images/img3.png" width="250" height="444" alt="Screen 3"/>
</div>
If I add a paragraph text between img1 and img2 they get separated (img2 goes to a newline)
What I'm attempting to do is this (with some space between the images):
[image1] [image2] [image3]
[text] [text] [text]
I haven't given the images their own individual class names because the images don't align horizontally to one another.
Add a container div for the image and the caption:
<div class="item">
<img src=""/>
<span class="caption">Text below the image</span>
</div>
Then, with a bit of CSS, you can make an automatically wrapping image gallery:
div.item {
vertical-align: top;
display: inline-block;
text-align: center;
width: 120px;
}
img {
width: 100px;
height: 100px;
background-color: grey;
}
.caption {
display: block;
}
div.item {
/* To correctly align image, regardless of content height: */
vertical-align: top;
display: inline-block;
/* To horizontally center images and caption */
text-align: center;
/* The width of the container also implies margin around the images. */
width: 120px;
}
img {
width: 100px;
height: 100px;
background-color: grey;
}
.caption {
/* Make the caption a block so it occupies its own line. */
display: block;
}
<div class="item">
<img src=""/>
<span class="caption">Text below the image</span>
</div>
<div class="item">
<img src=""/>
<span class="caption">Text below the image</span>
</div>
<div class="item">
<img src=""/>
<span class="caption">An even longer text below the image which should take up multiple lines.</span>
</div>
<div class="item">
<img src=""/>
<span class="caption">Text below the image</span>
</div>
<div class="item">
<img src=""/>
<span class="caption">Text below the image</span>
</div>
<div class="item">
<img src=""/>
<span class="caption">An even longer text below the image which should take up multiple lines.</span>
</div>
http://jsfiddle.net/ZhLk4/1/
Updated answer
Instead of using 'anonymous' div and spans, you can also use the HTML5 figure and figcaption elements. The advantage is that these tags add to the semantic structure of the document. Visually there is no difference, but it may (positively) affect the usability and indexability of your pages.
The tags are different, but the structure of the code is exactly the same, as you can see in this updated snippet and fiddle:
<figure class="item">
<img src=""/>
<figcaption class="caption">Text below the image</figcaption>
</figure>
figure.item {
/* To correctly align image, regardless of content height: */
vertical-align: top;
display: inline-block;
/* To horizontally center images and caption */
text-align: center;
/* The width of the container also implies margin around the images. */
width: 120px;
}
img {
width: 100px;
height: 100px;
background-color: grey;
}
.caption {
/* Make the caption a block so it occupies its own line. */
display: block;
}
<figure class="item">
<img src=""/>
<figcaption class="caption">Text below the image</figcaption>
</figure>
<figure class="item">
<img src=""/>
<figcaption class="caption">Text below the image</figcaption>
</figure>
<figure class="item">
<img src=""/>
<figcaption class="caption">An even longer text below the image which should take up multiple lines.</figcaption>
</figure>
<figure class="item">
<img src=""/>
<figcaption class="caption">Text below the image</figcaption>
</figure>
<figure class="item">
<img src=""/>
<figcaption class="caption">Text below the image</figcaption>
</figure>
<figure class="item">
<img src=""/>
<figcaption class="caption">An even longer text below the image which should take up multiple lines.</figcaption>
</figure>
http://jsfiddle.net/ZhLk4/379/
Best way is to wrap the Image and Paragraph text with a DIV and assign a class.
Example:
<div class="image1">
<div class="imgWrapper">
<img src="images/img1.png" width="250" height="444" alt="Screen 1"/>
<p>It's my first Image</p>
</div>
...
...
...
...
</div>
Since the default for block elements is to order one on top of the other you should also be able to do this:
<div>
<img src="path/to/img">
<div>Text Under Image</div>
</div
img {
display: block;
}
I created a jsfiddle for you here: JSFiddle HTML & CSS Example
CSS
div.raspberry {
float: left;
margin: 2px;
}
div p {
text-align: center;
}
HTML (apply CSS above to get what you need)
<div>
<div class = "raspberry">
<img src="http://31.media.tumblr.com/tumblr_lwlpl7ZE4z1r8f9ino1_500.jpg" width="100" height="100" alt="Screen 2"/>
<p>Raspberry <br> For You!</p>
</div>
<div class = "raspberry">
<img src="http://31.media.tumblr.com/tumblr_lwlpl7ZE4z1r8f9ino1_500.jpg" width="100" height="100" alt="Screen 3"/>
<p>Raspberry <br> For You!</p>
</div>
<div class = "raspberry">
<img src="http://31.media.tumblr.com/tumblr_lwlpl7ZE4z1r8f9ino1_500.jpg" width="100" height="100" alt="Screen 3"/>
<p>Raspberry <br> For You!</p>
</div>
</div>
You can use the HTML5 Caption feature.
Easiest way excpecially if you don't know images widths is to put the caption in it's own div element an define it to be cleared:both !
...
<div class="pics">
<img class="marq" src="pic_1.jpg" />
<div class="caption">My image 1</div>
</div>
<div class="pics">
<img class="marq" src="pic_2.jpg" />
<div class="caption">My image 2</div>
</div>
...
and in style-block define
div.caption: {
float: left;
clear: both;
}
Instead of images i choose background option:
HTML:
<div class="class1">
<p>Some paragraph, Some paragraph, Some paragraph, Some paragraph, Some paragraph,
</p>
</div>
<div class="class2">
<p>Some paragraph, Some paragraph, Some paragraph, Some paragraph, Some paragraph,
</p>
</div>
<div class="class3">
<p>Some paragraph, Some paragraph, Some paragraph, Some paragraph, Some paragraph,
</p>
</div>
CSS:
.class1 {
background: url("Some.png") no-repeat top center;
text-align: center;
}
.class2 {
background: url("Some2.png") no-repeat top center;
text-align: center;
}
.class3 {
background: url("Some3.png") no-repeat top center;
text-align: center;
}