Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Gabriel E
8,916 PointsAny way to get image responsive?
So I have an image that when I click it when the browser is resized to an phone, it appears larger, using jQuery. Right now when the browser is phone sized and I click it, the image doesn't fit with the screen, I guess the jQuery doesn't respond to the browser size. How would I fix that so the expanded image sizes with the browser? Here's the jQuery:
// problem: user when clicking on image goes to a dead end
// solution: create an overlay with the large image - Lightbox
var $overlay = $('<div id="overlay"></div>');
var $image = $("<img>");
$overlay.append($image);
$("body").append($overlay);
$(".img a").click(function(event){
event.preventDefault();
var imageLocation = $(this).attr("href");
$image.attr("src", imageLocation);
$overlay.show();
});
$overlay.click(function(){
$(this).hide();
});
1 Answer
Cindy Lea
Courses Plus Student 6,497 PointsHave you tried using a smaller image when its the phone size? I would put it in the query where it recognizes the phone size.