I have a problem. I want my footer
to be on top of everything else possible in my page. The trick is that I'm using Galleria plug-in and it has it's own style and for some reason even if I put z-index: 99999;
on my footer
it is still not on top.
This is galleria container, the main div of the plug-in.
.galleria-container {
overflow: hidden;
width: 960px; /* This value is changed by JS */
height: 520px; /* This value is changed by JS */
min-width: 960px;
}
This is my footer container
#footer
{
z-index: 9999;
width: 700px;
height: 500px;
position: absolute;
background-color: aqua;
}
Okey so when I load my website it is fine and I can see my footer, but when I resize windows thus executing this code it is hidden again.
$(".galleria-container").css("width", $(window).width());
$(".galleria-container").css("height", $(window).height());
You can use the CSS position property in combination with the z-index property to overlay an individual div over another div element. The z-index property determines the stacking order for positioned elements (i.e. elements whose position value is one of absolute , fixed , or relative ).
Use the CSS z-index property. Elements with a greater z-index value are positioned in front of elements with smaller z-index values. Note that for this to work, you also need to set a position style ( position:absolute , position:relative , or position:fixed ) on both/all of the elements you want to order.
If you set the width to 100% on the body element you will have a full page width. This is essentially equivalent to not setting a width value and allowing the default. If you want to use the body element as a smaller container and let the HTML element fill the page, you could set a max-width value on the body.
z-indicies are relative to other elements with a z-index in the same stacking context. Stacking context is defined by:
Put simply, whenever you have an element that matches any of the above, stacking context is reset and z-index is only relative to that container.
The simple answer to your question is one of two things:
Could try adding a z-index with !important on:
.galleria-container {
overflow: hidden;
width: 960px; /* This value is changed by JS */
height: 520px; /* This value is changed by JS */
min-width: 960px;
z-index: 9998!important;
}
Old topic, and old non-jQuery method, indeed. But a good approach to avoid being confused with arbitrary high z-index number is to set your object z-index to the highest index in the page + 1.
function topMost(htmlElement)
{
var elements = document.getElementsByTagName("*");
var highest_index = 0;
for (var i = 0; i < elements.length - 1; i++)
{
if (parseInt(elements[i].style.zIndex) > highest_index)
{
highest_index = parseInt(elements[i].style.zIndex);
}
}
htmlElement.style.zIndex = highest_index + 1;
}
But having a fast jQuery method would be nice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With