make an image fit into a container - Forum

Forum Navigation
You need to log in to create posts and topics.

make an image fit into a container

When I don't know what image the user will load, how do I make the image fit into a container if it is too large?

thanks.

 

 

 

@fkapnist you can use neoBackgroundImage command from neoBackground plugin.
Be sure to select "cover" or "contain" for the size property.

Regards.

 

 

fkapnist has reacted to this post.
fkapnist
Quote from luishp on April 2, 2023, 12:25 pm

@fkapnist you can use neoBackgroundImage command from neoBackground plugin.
Be sure to select "cover" or "contain" for the size property.

Regards.

 

 

Thanks!

I tried this but it wasn't working

BeginJS
imagew = document.getElementById('Image1').style.width;
imageh = document.getElementById('Image1').style.height;
if  (imagew > imageh) {
document.getElementById('Image1').style ="height:auto;width:791";
} else {
document.getElementById('Image1').style ="height:740;width:auto";
maximize();
}
EndJS