jquery - 查询/CSS : no success in to reveal a footer hidden behind a front-page

标签 jquery html css

我试图显示隐藏在首页后面的底部固定页脚(z-index:1)(z-index:999,其中应包含图片)在单击链接时运行脚本...

在现实生活中,使用触控板运行良好,并且用 2 个手指将图片移到顶部... 对于没有触控板的用户,我需要插入一个链接按钮来帮助显示页脚。

这是jsfiddle

    HTML -------
    <div class="container">
        <div class="front_page">
            <div class="text1">
                <p>Front-page .........</p>
            </div>
            <div class="text2">
               <a id="reveal" href="#">REVEAL FOOTER</a>
            </div>
        </div>
        <div class="footer" data-pages="reveal-footer">
           footer .........
         </div>
    </div>

    CSS --------
    .container { 
        width:100%; 
        position:relative; 
    }
    .front_page { 
        width:100%; 
        background: yellow; 
        position:absolute; 
        z-index:1000; 
    }
    .text1 {
        height: 200px;
    }
    .text2 {
        height: 400px;
        text-align: center;
        font-size: 32px;
    }

    .footer { 
        width:100%; 
        height:100px; 
        background: blue;
        color: white;
        position: fixed;
        bottom: 0;
        z-index: 1;
    }

   --SCRIPT 
    var myEl = document.getElementById('reveal');

    myEl.addEventListener('click', function() {
        var _elem = $('[data-pages="reveal-footer"]');
        setHeight();
            function setHeight(){
                var h = _elem.outerHeight();
                alert('_elem.outerHeight: ' + h);
                alert(JSON.stringify( _elem.prev()));
                _elem.prev().css({ 'margin-bottom':h })
            }
        $(window).resize(function(){
          setHeight();
        })  
        //alert('reveal the footer elemen _elem !' + _elem);
    }, false);

最佳答案

你只需要添加这一行:

$('.footer').css('z-index', 1001);

http://jsfiddle.net/tmzbsd0g/11

关于jquery - 查询/CSS : no success in to reveal a footer hidden behind a front-page,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32890471/

相关文章:

javascript - 使用 javascript 根据两个选项之一设置隐藏值

javascript - 回调问题-jquery

javascript - onfocus时如何更改文本框的背景颜色?

css - 忽略垂直 flex 元素内的文本对齐

jquery - css/jQuery 中的 z-index/opacity 无法正常工作

javascript - XMLHttpRequest 无法加载 http ://localhost:8089/jquery. Access-Control-Allow-Origin 不允许 Origin null

jquery - 如何将 jQuery 元素选择应用于字符串变量

wordpress - IE 9 毁了我的设计

html - 希望 DIV 在桌面上堆叠但在移动设备上彼此相邻

html - 使用相对位置的底部?