0

I know there are bunch of position:absolute and z-index questions on here but I have a slightly unique situation. I have a slide show that is position:relative; with a <h2>inside that is position:absolute. Now outside of the slideshow, I have a position:relative element that I want .slide-show-text to sit on top of .slide-show-wrap but z-index is not registering and the text sits under the wrap instead of on top.

<section>
    <div class="slideshow">
        <?php if( have_rows('landing_slides') ):
        while ( have_rows('landing_slides') ) : the_row();  ?>
          <div class="landing-bg"  data-type="background" data-speed="2" style="background-image: url('<?php the_sub_field("img"); ?>')">
            <h2 class="slide-show-text">
                <?php echo the_sub_field('img_text'); ?>
            </h2>
          </div> <!-- end landing bg -->
        <?php
        endwhile;
        else :
        endif;
        ?>

        </div> <!--end slide show -->
</section> <!-- /SECTION 1 -->

<div class="slideshow-text-wrap">
</div><!-- end slideshow text -->

.landing-bg {
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: fixed;
    width: 100%;
    z-index: 1001;
    position: relative;
    margin-top: 0;
}
.slick-track {
    height: 73vh;
    width: 100%;
    background-size: 100% 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 101;
}

.slide-show-text {
    bottom: -40px;
    font-family: "Teko", sans-serif;
    color: #f1e4b2;
    font-size: 50px;
    position: absolute;
    margin-left: auto;
    margin-right: auto;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 100001;
}
.slideshow-text-wrap {
    height: 126px;
    background-color: #e95526;
    z-index: 101;
    position: relative;
}
user2684452
  • 701
  • 2
  • 14
  • 31
  • 1
    read the duplicate at the end, you find many tricks there – Temani Afif Apr 08 '21 at 20:40
  • @TemaniAfif This is close, but doesn't specifically apply to my situation as I'm not trying to stack a parent on a child, I'm trying to stack an element that is a child in a container on top of a div outside of the that container that is not nested at all. – user2684452 Apr 09 '21 at 16:49

0 Answers0