Iframe background image or color

jamarsch
Kilo Explorer

I would like to either have a background image that displays in an Iframe or change the background color of an iframe from white to some other color

16 REPLIES 16

tltoulson
Kilo Sage

Hi John,



To accomplish this, you will want to change the background of page being embedded in the iFrame.   This may not be as simple as changing the page's html tag's background as any tags nested inside of the html tag could have a non-transparent background which would be displayed over top.   If you need more assistance, can you please provide some info about what you are embedding within the iFrame, possibly including some html?



Kind regards,



Travis


Hi Travis



I am really new to ServiceNow and still learning. I did try changing the back ground color but I had the problem you said. So I thoughyt I would try and add something to the CSS but that did not work either. This is what I said in the css



iframe#jamarsc_iframe2 {


background-color; "#acacac"


}


Hi John,



Two things, 1 your syntax for declaring a style is incorrect and 2 I dont think you can target an iframes background from the parent window. Try the code below and if it doesnt work, let me know are you using a ui macro, ui page, dynamic block... etc.



iframe#jamarsc_iframe2 {


background-color: #acacac !important;


}



** Note, you technically should never have to use the !important declaration. What it does is says "what ever the background-color style is on this element, ignore it and use the one with !important" typically you want to address this at its source


You would not try to access the iframe through the parent document as Alexander indicated.   At this point I will assume you are putting an iFame in the CMS.   Please provide more information if this is not the case.   ServiceNow drops your CSS styles into the iFrame content.   So you would treat your CSS selector as though it was already in the iFrame's document.   So if you put the declaration on html instead of iframe#jamarsc_iframe, this would impact both the parent documents html tag and the iFrame document's html tag.   This means you need to find a way to distinguish the documents.   If you could provide some specific implementation details regarding the html you are embedding in the iFrame I could assist further.