Reputation: 27
I want to achieve something like this:
|-----------| |-----------| |-----------|
| | | | | |
| image | | image | | image |
| | | | | |
|-----------| |-----------| |-----------|
image 1 image 2 image 3
There should be images side by side and also there should be description about these images under each image. I tried placing each image under its own "div" tag and also used display:inline property of css but above format is not getting displayed.
Upvotes: 2
Views: 12446
Reputation:
simplest solution:
<style type="text/css">
#container{
height:100%;
width: 100px;
}
</script
<body>
<div id="container">
<img id="a" src="" height="100" width="100" ></img><br /><p> this is text1</p><br />
<img id="b" src="" height="100" width="100" ></img><br /><p> this is text2</p><br />
<img id="c" src="" height="100" width="100" ></img><br /><p> this is text3</p><br />
<img id="d" src="" height="100" width="100" ></img><br /><p> this is text4</p><br />
</div>
</body
in src you put your image source, i have left blank and remember the width of your image should not exceed from the width of container.
Upvotes: 0
Reputation: 27624
You can do something like this
.container{
width: 150px;
margin-left: 10px;
float: left;
}
img{
width: 150px;
height:150px;
float: left;
}
.text{
text-align:center;
}
Upvotes: 2
Reputation: 16403
HTML5 introduced the figure
element that is used to connect an image with its caption with figcaption
.
<figure>
<img src="path/to/your/image" width="150px" height="150px" />
<figcaption>First image</figcaption>
</figure>
To get the figures side by side use the css
figure {
display:inline-block;
}
and to center the text below the image use
figcaption {
text-align: center;
}
See http://jsfiddle.net/TSWND/1/ for an example with 3 dummy images
Upvotes: 3
Reputation: 392
U can also use
<figure>
<img src="">
<legend></legend>
</figure>
Use this structure to contain your elements, tha float each figure element to the right or left and than add div with clear:both style.
Upvotes: 0
Reputation: 89
use float :left in css in middle DIV
<div>
<div> image code</div>// <-- use here float left
<div> discription code </div>//<-- use here float left
</div
Upvotes: 0