Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a div fullscreen and atop of all other elements with jQuery?

<div style="background-color:grey">
</div>

Is there an easy way to do it?

like image 492
user198729 Avatar asked Feb 07 '10 14:02

user198729


People also ask

How do you make a div appear on top of everything else on the screen?

Set the DIV's z-index to one larger than the other DIVs. You'll also need to make sure the DIV has a position other than static set on it, too. position relative and z index set to 999999999999999999999999999999999999999999999999999. in chrome.

How do I make a div visible on top of an html5 fullscreen video?

It's a simple trick, you need to add the maximum value of z-index which is (z-index: 2147483647;) in to the overlay element. That trick will solve your issue.

How do you make a full page container?

Firstly, you will want to drag a Container Element onto your page. From the right-hand menu of the editor, you will notice that there is a "Full Width" toggle. Toggling this will set this Container Element to full width on your page.

How do I make an element on top in CSS?

Using CSS position property: The position: absolute; property is used to position any element at the absolute position and this property can be used to stack elements on top of each other. Using this, any element can be positioned anywhere regardless of the position of other elements.


1 Answers

Define a style overlay or something like so:

<style>
  .overlay {  
    position:absolute;
    top:0;
    left:0;
    width:100%;
    height:100%;
    z-index:1000;
  }
</style>

Then you can add the new class like this using jQuery:

$('#myDiv').addClass('overlay');

If you want to add with a click event you would do something like this:

$('a').click(function(){
  $('#myDiv').addClass('overlay');
}

Or, you could add display:none to the .overlay class so it's hidden on page load, then have your jQuery click function show it like this:

$('a').click(function(){
  $('.overlay').show('slow');
}
like image 90
jay Avatar answered Oct 25 '22 06:10

jay