![]() ![]() |
| venkat_walking |
Nov 3 2009, 07:21 AM
Post
#1
|
|
Novice ![]() ![]() Group: Members Posts: 23 Joined: 22-May 09 Member No.: 8,678 |
Hi,
I want to ask can we show part of an image in <img> tag Suppose if the image is of 300x400 size, but I only want to show the vropped 100x100 part section that image (Not shrinking the image). Can we do this. Please tell me Venkat |
| Darin McGrew |
Nov 3 2009, 09:59 AM
Post
#2
|
|
WDG Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Root Admin Posts: 5,143 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
No, there is no way to use HTML to crop an image. Create another image that is a cropped version of the first, and use the cropped image instead.
-------------------- Darin McGrew
WDG Member since 1998 My involvement with the WDG is personal. The views I express here are mine alone and not those of my employer. |
| pandy |
Nov 3 2009, 10:37 AM
Post
#3
|
|
Don't like donuts. Don't do MySpace. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: WDG Moderators Posts: 7,207 Joined: 9-August 06 Member No.: 6 |
CSS clipping didn't use to work all that well, but it's been years since I tried so who knows?
http://www.w3.org/TR/CSS2/visufx.html#overflow-clipping A way to fake it, less elegantly, is with a border-less iframe. -------------------- “Never go to excess, but let moderation be your guide.”
– Cicero |
| Brian Chandler |
Nov 3 2009, 10:47 AM
Post
#4
|
|
Jocular coder ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,431 Joined: 31-August 06 Member No.: 43 |
No, there is no way to use HTML to crop an image. Create another image that is a cropped version of the first, and use the cropped image instead. I'm not sure this is strictly true. Put the image inside an iframe, with no scroll bars, the image positioned appropropriately, and I think you can display any desired crop of an image in an html document. (Two, if you count the iframe document as separate.) (Of course I'm not suggesting this is a particularly sensible idea.) |
| moo |
Nov 3 2009, 11:21 AM
Post
#5
|
|
Member ![]() ![]() ![]() Group: Members Posts: 45 Joined: 12-September 07 Member No.: 3,783 |
You could create a 100x100 div and apply the image as a background:
CODE <style> .clippedImage {display:block; position:relative; height:100px; width:100px; background:#fff none top left no-repeat;} .clippedImage img {display:none;} </style> <div class="clippedImage" style="background-image:url('path/to/image.jpg')"><img src="path/to/image.jpg" alt="image here for non-css enabled users" /> or something similar. |
| Christian J |
Nov 3 2009, 11:24 AM
Post
#6
|
|
¤¤¤¤¤¤¤¤¤ ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: WDG Moderators Posts: 2,370 Joined: 10-August 06 Member No.: 7 |
CSS clipping didn't use to work all that well, but it's been years since I tried so sho knows? http://www.w3.org/TR/CSS2/visufx.html#overflow-clipping I thought it was removed in CSS2.1, but it seems to be there too. You can also use CSS "overflow: hidden" on a parent block element with limited dimensions, or make the image the background of an element. You can also crop an image with PHP on the server. |
| venkat_walking |
Nov 5 2009, 06:42 AM
Post
#7
|
|
Novice ![]() ![]() Group: Members Posts: 23 Joined: 22-May 09 Member No.: 8,678 |
CSS clipping didn't use to work all that well, but it's been years since I tried so sho knows? http://www.w3.org/TR/CSS2/visufx.html#overflow-clipping I thought it was removed in CSS2.1, but it seems to be there too. You can also use CSS "overflow: hidden" on a parent block element with limited dimensions, or make the image the background of an element. You can also crop an image with PHP on the server. I haven't tried any of the above solution yet. I will try in a day or two. But can we do this with Jquery. Thanks Venkat. |
![]() ![]() |
|
Lo-Fi Version | Time is now: 21st November 2009 - 03:38 AM |