i am taking an image from a source, say, facebook. now when i want to insert that image in a container with fixed width and height, the image stretches to fit that space. is there a way the image can display in its normal size and the rest of the area clipped out?
+4
A:
<div style="width: 100px; height: 100px; background-image: url(your image); background-repeat: no-repeat;"></div>
Then in the above DIV you can play with CSS
- width/height
- background-position
to create different crop effects.
Marco Demajo
2010-04-12 16:29:50
A:
Use this : http://www.w3schools.com/css/pr_background-position.asp
background-position: 5px 5px;
and then set the height and width of the div
height: 55px;
width: 55px;
AjayP
2010-04-12 16:30:40
+1
A:
You can use the CSS clip
property:
#image_element
{
position:absolute;
clip:rect(0px,60px,200px,0px);
}
The downside of using clip
is that the element has to be absolutely positioned, and is only available with the 'rect' shape.
See:
David Thomas
2010-04-12 17:35:41