Wednesday, December 3, 2008

Javascript image clipping

I was looking all over the place for some javascript code to clip images. The answer was right under my nose. What I needed was already built into HTML.

HTML DOM clip Property

The clip property sets the shape of an element.

What happens if an image is larger than the element it goes inside? - The "clip" property lets you specify the dimensions of an element that should be visible, and the element is clipped into this shape, and displayed.

Object.style.clip=rect(top,right,bottom,left)auto

rect(top,right,bottom,left) - Sets the shape of the element
auto - The browser sets the shape of the element

More... HTML DOM clip Property

ASP.Net Feeds