0
How to align an image in the position one wishes for?
2 Antworten
+ 1
You can make the container, that contains the image, relative and the image itself, absolute. Once you've done this then you can control the absolute position (with top, right, left and bottom values) of the image in the container it's in.
Example (HTML and CSS):
//The HTML part
<body>
<div id="box">
<img id="item" src="#" alt="test" />
</div>
</body>
//The CSS part
#box {
width:500px;
height:500px;
position:relative;
background-color:blue;
}
#item {
width:50px;
height:50px;
position:absolute;
top:200px;
left:200px;
}
//This will put the image exactly 200 pixels from the top and 200 pixels from the left of the #box container
0
Let's talk in terms of HTML5, use CSS 'float' property to control the alignment of image.
.left {
float: left;
}
.right {
float:right;
}
For Example:
For aligning image to the left
<img src="smiley.jpg" class="left">