我在页面上有一个垂直居中的幻灯片,但是我想以某种方式添加一个“限制”,可以说它在较小的屏幕上向上滑动页面的高度。
http://www.visioncreativegroup.com.au/demos/bps/index.php/production/theatre
如果您调整窗口大小,它将达到幻灯片位于导航栏和主徽标顶部的位置。基本上,一旦屏幕尺寸达到足够小的尺寸,它就需要停在这些元素的底部。
这可能吗?
我在页面上有一个垂直居中的幻灯片,但是我想以某种方式添加一个“限制”,可以说它在较小的屏幕上向上滑动页面的高度。
http://www.visioncreativegroup.com.au/demos/bps/index.php/production/theatre
如果您调整窗口大小,它将达到幻灯片位于导航栏和主徽标顶部的位置。基本上,一旦屏幕尺寸达到足够小的尺寸,它就需要停在这些元素的底部。
这可能吗?
我会将网站的幻灯片部分和标题部分分开。所以你有 3 个水平切片:页眉、幻灯片、页脚。然后您可以将幻灯片置于中间部分的中心,并且它永远不会超过标题。
试试我为您设置的这个小演示,看看您是否可以将项目中的 HTML 切换为类似的内容:
HTML:
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Demo</title>
            <!-- Insert below CSS here -->
            <!-- Insert JQuery here (http://code.jquery.com/jquery-latest.min.js) -->
            <!-- Insert below JS here -->
    </head>
    <body>
        <div id="shell">
            <div id="head">Header.</div>
            <div id="slideshow">Slideshow.</div>
            <div id="foot">Footer.</div>
        </div>
    </body>
</html>
CSS:(主要用于演示):
*{ margin: 0; padding: 0; }
div#head{ height: 200px; background: blue; }
div#foot{ height: 100px; background: red; }
div#slideshow{ height: 300px; background: green; }
JavaScript:
// Fix position initially and on each window resize.
$(window).resize(fix);
$(document).ready(fix);
function fix()
{
    // Work out position value.
    var base = $("div#slideshow").position().top;
    var middle = $(window).height() / 2;
    var hw = $("div#slideshow").height() / 2;
    // Position top either at the position determined above, or 0 if it bypasses the top of the page.
    var destination = Math.max(middle - base - hw, 0);
    $("div#shell").offset({ top: destination });
}
position: absolute;从.production-scroll班级中删除
如果没有必要position: fixed;也删除#sticky-footer