I have an image with the dimensions of 1200 x 200px. In the center of this image, there is a space measuring 500 x 200px which represents the main content of the entire image. Flanking this main content are additional contents on each side. It is important to note that all these elements exist within a single image.
When the window width is reduced, the first thing to be cut off should be the additional content, while maintaining the height of the image. However, once the window width is reduced below the width of the main content (resulting in the cutting off of all additional content), the image should then be resized proportionally, affecting its height as well.
My questions:
- Is it possible to achieve this using only CSS?
- If not, are there any JS libraries available for this purpose?
- If not, how should I structure the HTML, CSS, and JS to make it work?
Example of a full-width banner: Take note that there is a main content area surrounded by additional content on either side.
https://i.sstatic.net/csRha.png
The following image should help illustrate: I have attempted to simulate a resizing of the window width from 1200px to 1000px and eventually down to 500px (without affecting the height), followed by a further reduction to 350px where the image is resized proportionally.