Override body style for content in an iframe

前端 未结 10 937
青春惊慌失措
青春惊慌失措 2020-11-22 01:10

How can I control the background image and colour of a body element within an iframe? Note, the embedded body element has a class, and the iframe i

10条回答
  •  隐瞒了意图╮
    2020-11-22 01:23

    I have a blog and I had a lot of trouble finding out how to resize my embedded gist. Post manager only allows you to write text, place images and embed HTML code. Blog layout is responsive itself. It's built with Wix. However, embedded HTML is not. I read a lot about how it's impossible to resize components inside body of generated iFrames. So, here is my suggestion:

    If you only have one component inside your iFrame, i.e. your gist, you can resize only the gist. Forget about the iFrame.

    I had problems with viewport, specific layouts to different user agents and this is what solved my problem:

    
    
    
    
    
    

    The logic is to set gist (or your component) css based on user agent. Make sure to identify your component first, before applying to query selector. Feel free to take a look how responsiveness is working.

提交回复
热议问题