0

How can we change the width and height of an image, without actually changing how it looks or stretching it. For example, I want to change how much space this image covers, but I don't want to change how it actually looks:

I want to change how much space this image occupies, without actually changing how it looks, without stretching it. I have tried object-fit, but I don't know how to use it and how it works. Any solutions?

  • Images have a `height` and `width` property. – Andy Ray Dec 17 '21 at 04:40
  • Yeah but that changes how they look. I don't want to do that. –  Dec 17 '21 at 05:16
  • Does this answer your question? [Centering a background image, using CSS](https://stackoverflow.com/questions/2643305/centering-a-background-image-using-css) – Andy Ray Dec 17 '21 at 05:19
  • No. I want to change the amount of space an image () covers, without actually changing how it looks (physically changing its width or height). –  Dec 17 '21 at 05:35
  • 1
    You may have a clear idea of what you want in your head but this question isn't clear. If you also have specific code/html/css you're trying to use, that might help us understand if this is an XY problem. I also suggest [how to ask](https://stackoverflow.com/help/how-to-ask) and [how to create a minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) to help others understand what you're asking – Andy Ray Dec 17 '21 at 05:45
  • Alright look. I have an image and some text above it. When I hover on that text it should turn orange. But now, only when I hover on the top part of the text, it turns orange, but if I hover on the part, it doesn't turn orange, because the image occupies some of that area. So, right now, I want to change how much space the image covers, so it doesn't cover any space around the text, without actually changing how the image looks. –  Dec 17 '21 at 06:05

1 Answers1

0

try to add padding or margin to it.

e.g.

seantsang
  • 1,123
  • 2
  • 7
  • 20
  • That changes its position. It should remain where it is, and should change how much space it occupies, without actually changing how it looks by stretching it or anything like that. –  Dec 17 '21 at 05:17
  • I want to change the amount of space an image () covers, without actually changing how it looks (physically changing its width or height). –  Dec 17 '21 at 05:35