- This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
is there a way to resize an image based on its width? for instance, if the image is 300px or larger, it would resize to 500px; if the image is less than 300px wide, then it would remain its original width..?
i feel like it might be possible with javascript but i don’t really know javascript so i could be completely wrong. ideas?
i should clarify — i have a div with a width of 500px. contained in that div are many differently-sized images; i want to assign images that are 350px or larger to width: 100% and allow images smaller than 350px to remain as they are. is that possible?
jQuery(javascript) would work:
$(document).ready(function(){
$('div img').each(function(){
if($(this).width() > 350){
$(this).css('width', '100%');
}
});
});
you are amazing, thanks! works like a charm.
Is there any way to accomplish with scss? I have an image slider. If the image is profile instead of landscape I want to change the width to 100%.
You might do better starting a new thread rather than resurecting a dead thread from 4 years ago.