I limit the height, for example, using max-height. I'm trying to set the width of the fit-content, then black bars are added to narrow images, and wide images go beyond the boundaries of the container. I want to get the following result: the height is limited to a certain value, the width adjusts to the width of the image without black bars.
Actual:

Expecting:
