Link to home
Start Free TrialLog in
Avatar of Melody Scott
Melody ScottFlag for United States of America

asked on

Bootstrap img-responsive question

If I have an image inside a link, like:
<a href="/menu/main_courses.html"><img src="/images/linkshare/2015/DC-15.jpg" alt="promo" width="720" height="554"/></a>,

Where do I put the  class="img-responsive"? In the a tag or the img tag?
Avatar of Member_2_6317024
Member_2_6317024
Flag of United States of America image

<img src= class = alt=/>
SOLUTION
Avatar of Nrupendra Nath Panigrahi
Nrupendra Nath Panigrahi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Prasadh Baapaat
Prasadh Baapaat
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Melody Scott

ASKER

thanks!
OK, I have done that here: http://dev2.magickitchen.com/landing/linkshare/2015/SP-FD.html

No width or height, and img-responsive class on the image. But all the mobile emulators I have looked at show the image as not being responsive.
Avatar of Nrupendra Nath Panigrahi
Nrupendra Nath Panigrahi

<div style="width:100%;">
  <div style="width:720px; margin-left:auto; margin-right:auto;"><a href="http://www.magickitchen.com/menu/main_courses.html"><img src="/images/linkshare/2015/SP-FD.jpg" alt="promo" class="img-responsive" border="0"></a></div></div>

Open in new window


You fixed a div width 720px.so its not seem tobe responsive

You remove that style and check
I checked the link and Nrupendra is correct.

The img-responsive class assigns a width=100% to the image, so in your page since your div is 720 px the images also has a width of 720px.

in higher resolutions the image will be shown in its ACTUAL width in pixels.
Argh, Of course. Thanks for pointing that out.
But now the photo is not centered.
http://dev2.magickitchen.com/landing/linkshare/2015/AG-11.html

I have tried using text-align:center on this and it doesn't always work:
http://dev2.magickitchen.com/landing/linkshare/2015/CODE15.html

I've also tried: class="img-responsive center-block"

http://dev2.magickitchen.com/landing/linkshare/2015/AG-FD.html
Never mind, I figured that out, it was the width again. OK, I think I have it hammered into my head now, thanks!!