How do you make the lightbox appear in front of everything?

Asked

Viewed 368 times

0

I use the Banner do Ebit for customers to be able to evaluate the purchase on the website, however the lightbox it always appears behind all the elements of the page. How to make him appear in front of everything?

The code below is a short version of what is required for the banner to load.

<a id="bannerEbit"></a> <!-- Aqui ele carrega o banner com o background "banner.gif" do próprio Ebit -->

<script id="getSelo" src="https://imgs.ebit.com.br/ebitBR/selo-ebit/js/getSelo.js?storeId&lightbox=true"></script> <!-- Script do ebit de onde vêm as informações e o lightbox -->

as ALMOST should be (just to see the lightbox in this example without the background) Exemplo de como QUASE deve ser (só para verem o lightbox)

as it is (Notice that the shadow still appears behind, ie the lightbox is loading behind everything) como está

  • Tried to configure z-index?

  • how to configure z-index by having an external script by calling a variable?

  • Z-index is a CSS class that controls the "Z-axis" of the elements. Summarizing it brings one element forward of the other, provided that the element also has a set "position". The bigger the z-index, the more the Element comes forward from the others. Here you can read about https://www.w3schools.com/cssref/pr_pos_z-index.asp

1 answer

1


You can load the script by Javascript (not jQuery) using create.Element and then detect when the script was loaded on the page, with this you can force the z-index the elements of eBit with .onload.

eBit’s elements (background and box) are two ids: #dark and #boxLight respectively. Then do so:

var s = document.createElement("script"); 
s.src = "https://imgs.ebit.com.br/ebitBR/selo-ebit/js/getSelo.js?storeId&lightbox=true"; 
s.id = "getSelo"; 
document.body.appendChild(s);

s.onload = function(){
   $("#dark, #boxLight").css('z-index','99999999');   
}

Don’t forget to put your storeId in the URL.

  • then it doesn’t work with that jQuery?

  • @Cyanoobarbarossa will not work no.

  • not because there is no variable s

  • @Cyanorbarossa Might work with jQuery if you add a setTimeout

  • can give an example?

  • @Cianobarbarossa setTimeout(function(){ $("#dark, #boxLight").css('z-index','99999999') },1000);

  • worked with Javascript thanks

  • How do you know what ebit ids are?

  • @Cyanorbarossa Just look at the page code.

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.