image - Specifying width and height as percentages without skewing photo proportions in HTML -


I was thinking that in the width and height attributes, can I specify width and height as percentages?

Okay, I think it's clear, because when I try, it changes its shape, but it seems to obliterate the quality of my image.

Here is an example of my markup with certain properties:

   

Now, trying to measure this scale, say half by percentage:

   

I get absolutely something:

   

I think that I only consider my percentage markup or something wrong because my second and third example has a visually different difference.

Update: Thank you to all for all helpful posts!

I actually really created a pat for JP suggestion, because with a snippet he has suggested, I can actually modify the selector and all of my Fancybox affected images such as- Then:

  apply to $ ('img.FancyBox'). Each (function () {$ (this) .Wide ($ (this). Width () * 0.25);});  

It's so great!

You can check the live effect here on your site:

It is working very well, considering the fact that once I get it done in my SQL If I connect to Server DB, then I can apply a jQuery snippet to all Fancy Box square images on my product pages.

Thanks guys!

In your second example, the percentage width is actually applying for the container, your Lt; Img & gt; is inside, and not the actual size of the image, assuming that you have the following markup:

   

Your resulting image will be 500 pix width and 300 pixels tall.

Change the size of jQuery

If you are trying to reduce 50% of your width, you can do it with a snippet of jQuery Can:

  $ ("img") .each (function () {var $ img = $ (this); $ img.width ($ img.width () * .5) ;});  

Just make sure that you first remove any height / width = 50% attributes.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -