如何用指定CSS将自定义元素覆盖Power BI全屏嵌入Iframe?
Overlaying Custom Elements on Fullscreen Power BI Embedded Iframes
Got it, let's walk through how to make sure your custom element stays on top of the fullscreen Power BI iframe. The main hurdle here is that Power BI's fullscreen iframe uses a very high z-index, so we need to crank up our element's priority to beat it.
Here's the revised code for your custom element, incorporating the critical styles you mentioned plus a couple of tweaks to ensure it works as expected:
<div onclick="console.log('test')" ng-if="vm.openWidget === vm.wid" style=" position: fixed !important; bottom: 50px; right: 50px; height: 50px; width: 200px; background: red; z-index: 2147483647 !important; /* Max safe z-index to outrank Power BI's iframe */ pointer-events: auto !important; /* Ensure clicks register on your element */ " > <div style="color: white;">Your Custom Content</div> </div>
Why this works:
- Max z-index:
2147483647is the highest valid integer for z-index (browsers cap it at this value), so it will always sit above the Power BI iframe's z-index. !importantflags: These force your styles to override any conflicting styles from the Power BI embed or parent page stylesheets—critical for ensuringposition: fixedand z-index stick.- Pointer events: Adding
pointer-events: auto !importantmakes sure the click handler on your div actually fires, even if there are other layered elements beneath it.
Quick checks to avoid issues:
- Ensure your custom element is rendered in the main parent page, not inside the Power BI iframe. Elements inside the iframe can't escape its context to overlay on top.
- If you're still having trouble, use your browser's dev tools to inspect the Power BI iframe's z-index—though
2147483647should still outrank it every time.
内容的提问来源于stack exchange,提问作者Rodney Wormsbecher
相关产品推荐
相关产品推荐

