Change body background color in an iframe using one css file

后端 未结 6 1214
隐瞒了意图╮
隐瞒了意图╮ 2020-12-18 07:51

Using a iframe where I call a site from my webspace, Using one css file with body {background-color: #222}.

The iframe src also use this CSS file. The P

6条回答
  •  甜味超标
    2020-12-18 08:22

    This question is similar to How to apply css to iframe content?. Basically you can use jQuery to change the CSS properties in the iframe

    $('#yourIframe').contents().find('body').css({
        background-color: '#333333'
    });
    

    Edit: You may need to add that when the iframe loads:

    $('#yourIframe').load(function(){ 
        $(this).contents().find('body').css({
            background-color: '#333333'
        });
    });
    

提交回复
热议问题