Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defining HTML doctype breaks slider 100% height #846

Open
psot opened this issue Aug 16, 2024 · 0 comments
Open

Defining HTML doctype breaks slider 100% height #846

psot opened this issue Aug 16, 2024 · 0 comments

Comments

@psot
Copy link

psot commented Aug 16, 2024

I have a simple slider setup to expand to 100% height:

<section class="slider">
    <div class="header-slider-controls tns-controls">
        <button data-controls="prev" tabindex="-1" aria-controls="tns1"><i class="fas fa-chevron-left"></i></button>
        <button data-controls="next" tabindex="-1" aria-controls="tns1"><i class="fas fa-chevron-right"></i></button>
    </div>
    <div class="header-slider">
        <div class="slide" style="background-image: url(/media/fa4lfyej/shutterstock_208088251_africa_morocco_mpaharika.jpg)">
            <a class="content-wrapper" href="">
                <p>some text</p>
            </a>
        </div>
        <div class="slide" style="background-image: url(/media/4legplnz/shutterstock_1195370017_europe_norway_winter_harbor.jpg)">
            <a class="content-wrapper" href="">
                <p>some text</p>
            </a>
        </div>
    </div>
</section>

Using these settings:

<script>
    var slider = tns({
        container: '.header-slider',
        items: 1,
        slideBy: 'page',
        autoplay: true,
        autoplayButtonOutput: false,
        autoplayTimeout: 7500,
        controlsContainer: '.header-slider-controls'
    });
</script>
<style type="text/css">
    section.slider { display: block; height: 100%; 100%; }
    .slider, .header-slider { height: 100%; }
    .header-slider div.slide { color: #fff; height: 100%; background-size: cover; background-repeat: no-repeat; background-position: center center /* 50% 40% */; position: relative; }
    .header-slider div.slide .content-wrapper { position: absolute; width: 100%; height: 100%; top: 0px; bottom: 0px; color: #fff !important; display: flex;  }
    /* misc */
    .tns-nav { text-align: center; margin: 10px 0; position: absolute; bottom: 10px; width: 100%; z-index: 999; }
    .tns-nav > [aria-controls] { width: 11px; height: 11px; padding: 0; margin: 0 5px; border-radius: 50%; background: #ddd; border: 0; }
    .tns-nav > .tns-nav-active { background: #999; }
    .tns-controls { position: absolute; z-index: 998; height: 50%; width: 100%; display: flex; align-items: flex-end; justify-content: space-between;}
    .tns-controls:hover button { opacity: 1; }
    .tns-controls button { font-size: 3em; color: #fff; background: rgba(255,255,255,0.2); padding: .25em; border: none; opacity: 0.75; }
    .tns-controls button:hover { background: rgba(255,255,255,0.4); }
</style>

If I add a <!DOCTYPE html> the slider renders slides with 0px height.

The only workaround I found so far is adding this style:

.tns-outer, .tns-ovh, .tns-inner, .tns-slider { height: 100%; }

Demo link/slider setting:

Tiny-slider version: 2.9.3 and 2.9.4
Browser name && version: Tested on Firefox, Edge, Chrome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant