79087327

Date: 2024-10-14 18:40:56
Score: 0.5
Natty:
Report link

In Firefox, the width of the img container isn't random. In fact it is the original width of the img (600px), CSS alone can't determine the rendered width when the image's height is based on a percentage.. What exactly do you want to achieve? if you really want to force it, use JS to determine the image width on page load.

function changeWidth() {
  const container = document.querySelector('img-container');
  const img = document.querySelector('img1');
  container.style.width = img.clientWidth + 'px';
}
window.onload = changeWidth
windw.onresize = changeWidth
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Math Freak