Background-size: cover and-webkit-background-size,
When using jade and styl to write a mobile phone page and the element is a background image, background-size cover is often used, which means that the background image is filled with the entire element, and ensure the aspect ratio of the background image.
That is, when the image is smaller than the container, and the background-repeat cannot be used to implement the current situation, we can use cover; enlarge the background image to the appropriate container size.
Or set the width and height of the element to the width and height of the background image, and set margin-left to half the width of the element to center the element on the mobile phone screen.
One of the newly added attributes of css3 is background-size: cover. How can this problem be compatible with IE ??
Our solution to this problem is to use img;
Listen to the resize event of the window.
The callback function logic of resize is as follows:
When the window aspect ratio is greater than the image aspect ratio, the image width is set to 100%, and the height is set to auto
When the aspect ratio of a window is smaller than the aspect ratio of an image, the image height is set to 100%, and the width is set to auto.
During dom loaded, call the resize callback function first.
One of the newly added attributes of css3 is background-size: cover. How can this problem be compatible with IE ??
CSS 3 is supported only after ie9, but not before.