0

How to align an image in the position one wishes for?

21st Mar 2017, 2:32 PM
Neeran
Neeran - avatar
2 Respostas
+ 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
21st Mar 2017, 4:56 PM
Ghauth Christians
Ghauth Christians - avatar
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">
21st Mar 2017, 4:20 PM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar