Background image size within an iframe is stretched

南楼画角 提交于 2020-01-07 03:49:52

问题


I'm having a weird issue where background images within an iframe are being stretched to the height of the iframe rather than the size of the div that they're attached to.

Basically, I have a page made by a different agency that that will live within an iframe on the client's main site. This page has 4 or 5 sections with background images using the following css:

background-image: url(../images/bkg1.jpg);
background-attachment: fixed;
background-position: top;
background-repeat: no-repeat;
background-size: cover;

This all works well when we view the document by itself, but when placed within an iframe, the background image size is no longer relative to the div with these styles, it's relative to the entire iframe. We were planning on having the iframe be the height of the document (around 7500px) within it so it looked a little more integrated, but what this does is stretch all of the background images to 7500px. I'm at a loss for why this is happening. Any direction to look in or if anyone has run across this problem before would be a huge help. Thanks!

来源:https://stackoverflow.com/questions/44506160/background-image-size-within-an-iframe-is-stretched

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!