回复讨论(解决方案)
用jquery scroll()来侦测是否浏览到第三屏,然后添加一个class,使得background-position, fixed.
jQuery(window).scroll(function(){ if(jQuery(window).scrollTop() > 1399){ jQuery('html').addClass('scrolled'); }else{ jQuery('html').removeClass('scrolled'); }});
html { background:url(image.jpg); background-repeat: no-repeat; background-position: top left;}html.scrolled { background-attachment:fixed; background-position: bottom left;}
算是笨方法 你参考
无标题文档 *{padding:0; margin:0;}body{background:url(http://b.hiphotos.baidu测试数据/album/w%3D2048/sign=19d4e347c2fdfc03e578e4b8e0078694/83025aafa40f4bfb2ac58bed024f78f0f7361875.jpg) 50% 0 no-repeat;}body.over{background:url(http://b.hiphotos.baidu测试数据/album/w%3D2048/sign=19d4e347c2fdfc03e578e4b8e0078694/83025aafa40f4bfb2ac58bed024f78f0f7361875.jpg) 50% bottom no-repeat fixed;}.box{height:5000px;}
查看更多关于背景图片如果小于页面高度时,背景图片固定这个样式怎么写。_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did103191