/ Published in: HTML
dynamically crop (but not resize) an image using css. Could add sizes to the img css to change size but it will look crap.
Expand |
Embed | Plain Text
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <style type="text/css" media="screen"> div.crop { height: 300px; width: 350px; overflow: hidden; } div.crop img { margin: -300px -200px 0 0; } </style> </head> <body> <div class="crop"> <img src="paper-sculpture-large.jpg" class="crop" alt="Paper Sculpture Large"> </div> </body> </html>
You need to login to post a comment.
