一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

h5页面背景图很长要有滚动条滑动效果实现代码

时间:2022-06-25 17:52:45 编辑:袖梨 来源:一聚教程网

本篇文章小编给大家分享一下h5页面背景图很长要有滚动条滑动效果实现代码,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。

背景图铺满页面,要求有滚动条可以滑动,思路是用js获取背景图片的高,在获取当前窗口的高,两者比较,当窗口的高小于背景图片的高,把窗口的高设置成背景颜色的高。反之就是窗口的高。



       




长背景图测试/title>
<style type="text/<a href="http://www.111com.net/cssdiv/css.html" target="_blank">css</a>">
        //body里面的属性min-height是关键,网上说直接设置成100vh即可,如果不可以可以自己微调
    body{
        background:url(./images/download_bg.png) no-repeat;
        background-size:100%;
                //方案1
        min-height: 185vh;
                //方案2,本质等价于方案一,如果两个方案是同时开启,则会使用高度更小的那个,已测试
                //
    }
 
    #btn{
        margin-top: 150px;
        text-align: center;
    }  
     
</style>
<body>
 
<div id="btn">
    <a href=" http://www.cnblogs.com/fanbi">
    <a href="https://img.111cn.net./images/download_btn.png" class="js-smartPhoto-pc" target="_blank"><img src="https://img.111cn.net./images/download_btn.png" width="90%" alt="跳转到某个网页地址"/></a></a>
</div>   
 
</body>
</html></pre>
<p>
	这是网上的代码。
</p>
<p>
	改动了下
</p>
<pre class="brush:xhtml;">body{
    background: -webkit-linear-gradient(to bottom , #699eef, #8e92ef); 
    background: -o-linear-gradient(to bottom , #699eef, #8e92ef); 
    background: -moz-linear-gradient(to bottom , #699eef, #8e92ef); 
    background: linear-gradient(to bottom , #699eef, #8e92ef);
  
}
.app {
    width: 100%;
    /*  */
    min-height: 120vh;
    /* position: fixed; */
    /* top: 0; */
    /* left: 0; */
    background: url('../../images/bg.jpg') no-repeat;
    background-size: 100% auto;
    
}</pre>
<p>
	给body加了个跟图片颜色一样的背景色
</p>                    


                    <div class="articles">
                        <div class="tit02">
                            <h4>相关文章</h4>
                        </div>
                        <ul>
                                                                                                <li>
                                        <a target="_blank" href="/new/422345.htm">2024金摇杆奖年度游戏名单</a>
                                        <span>11-22</span>
                                    </li>
                                                                    <li>
                                        <a target="_blank" href="/new/422344.htm">用针在纸上绣画是哪种非遗技艺   蚂蚁新村11月21日答案最新</a>
                                        <span>11-22</span>
                                    </li>
                                                                    <li>
                                        <a target="_blank" href="/new/422343.htm">重返未来1999纸信圈儿什么时候up 为什么故事集卡池活动介绍</a>
                                        <span>11-22</span>
                                    </li>
                                                                    <li>
                                        <a target="_blank" href="/new/422342.htm">重返未来1999雾中盛会怎么玩 UTTU聚光专栏雾中盛会活动介绍</a>
                                        <span>11-22</span>
                                    </li>
                                                                    <li>
                                        <a target="_blank" href="/new/422341.htm">光遇姆明季后续版本怎么玩 光遇音乐节宴会节活动介绍</a>
                                        <span>11-22</span>
                                    </li>
                                                                    <li>
                                        <a target="_blank" href="/new/422340.htm">无期迷途四星装束是谁 无期迷途首个四星装束剪影介绍</a>
                                        <span>11-22</span>
                                    </li>
                                                                                    </ul>
                    </div>
                </div>


                <div class="pages art-detail">

                </div>












            </div>
        </div>
    </div>
</div>

<div class="hot-column">
    <div class="cont">
        <div class="tit">
            <h4>热门栏目</h4>
        </div>
        <ul class="clearfix">
            <li>
                <h6><a href="/list-1/" target="_blank">php教程</a></h6>
                <a href="/list-45/" target="_blank">php入门</a>
                <a href="/list-46/" target="_blank">php安全</a>
                <a href="/list-47/" target="_blank">php安装</a>
                <a href="/list-48/" target="_blank">php常用代码</a>
                <a href="/list-49/" target="_blank">php高级应用</a>
            </li>
            <li>
                <h6><a href="/list-2/" target="_blank">asp.net教程</a></h6>
                <a href="/list-78/" target="_blank">基础入门</a>
                <a href="/list-79/" target="_blank">.Net开发</a>
                <a href="/list-80/" target="_blank">C语言</a>
                <a href="/list-81/" target="_blank">VB.Net语言</a>
                <a href="/list-82/" target="_blank">WebService</a>
            </li>
            <li>
                <h6><a href="/list-6/" target="_blank">手机开发</a></h6>
                <a href="/list-208/" target="_blank">安卓教程</a>
                <a href="/list-209/" target="_blank">ios7教程</a>
                <a href="/list-210/" target="_blank">Windows Phone</a>
                <a href="/list-211/" target="_blank">Windows Mobile</a>
                <a href="/list-212/" target="_blank">手机常见问题</a>
            </li>
            <li>
                <h6><a href="/list-3/" target="_blank">css教程</a></h6>
                <a href="/list-99/" target="_blank">CSS入门</a>
                <a href="/list-100/" target="_blank">常用代码</a>
                <a href="/list-101/" target="_blank">经典案例</a>
                <a href="/list-102/" target="_blank">样式布局</a>
                <a href="/list-103/" target="_blank">高级应用</a>
            </li>
            <li>
                <h6><a href="/list-4/" target="_blank">网页制作</a></h6>
                <a href="/list-136/" target="_blank">设计基础</a>
                <a href="/list-137/" target="_blank">Dreamweaver</a>
                <a href="/list-138/" target="_blank">Frontpage</a>
                <a href="/list-139/" target="_blank">js教程</a>
                <a href="/list-140/" target="_blank">XNL/XSLT</a>
            </li>
            <li>
                <h6><a href="/list-7/" target="_blank">办公数码</a></h6>
                <a href="/list-236/" target="_blank">word</a>
                <a href="/list-237/" target="_blank">excel</a>
                <a href="/list-238/" target="_blank">powerpoint</a>
                <a href="/list-239/" target="_blank">金山WPS</a>
                <a href="/list-240/" target="_blank">电脑新手</a>
            </li>
            <li>
                <h6><a href="/list-11/" target="_blank">jsp教程</a></h6>
                <a href="/list-68/" target="_blank">Application与Applet</a>
                <a href="/list-69/" target="_blank">J2EE/EJB/服务器</a>
                <a href="/list-70/" target="_blank">J2ME开发</a>
                <a href="/list-71/" target="_blank">Java基础</a>
                <a href="/list-72/" target="_blank">Java技巧及代码</a>
            </li>
        </ul>
    </div>
</div>

<div class="footer">
    <div class="cont">
        <p>
            <a href="/" target="_self">一聚教程网</a>|
            <a href="javascript:;" class="about" target="_self">关于我们</a>|
            <a href="javascript:;" class="contact" target="_self">联系我们</a>|
            <a href="javascript:;" class="gg_contact" target="_self">广告合作</a>|
            <a href="javascript:;" class="friend_link" target="_self">友情链接</a>|
            <a href="javascript:;" class="copyright_notice" target="_self">版权声明</a>
        </p>
        <p>
            <span>copyRight@2007-2022 www.111CN.NET AII Right Reserved <a href="https://beian.miit.gov.cn/" target="_blank" class="beian"></a></span>
        </p>
        <p>
            <span>
                网站内容来自网络整理或网友投稿如有侵权行为请邮件:111cn.com@163.com 我们24小时内处理
            </span>
        </p>
    </div>
</div>
<script>
    var advData = {"img_fixed_pc_adv":"https:\/\/img.111cn.net\/uploads\/20240509\/663c2e9729f58.jpg","img_fixed_mob_adv":"https:\/\/img.111cn.net\/uploads\/20240509\/663c2e8793225.jpg","url_adv":"http:\/\/shop.hushen.cn\/shop\/c\/baojianpin.html","str_adv":"\u864e\u795e\u5546\u57ce\uff1a\u5173\u7231\u7537\u6027\uff0c\u66f4\u61c2\u7537\u4eba\u3002\u89e3\u51b3\u5927\u4f17\u7684\u7537\u8a00\u4e4b\u9690","img_popup_adv":"https:\/\/img.111cn.net\/uploads\/20240509\/663c2e748238d.png","pc_show_img":"2","pc_show_popup":"2","pc_show_video":"2","mob_show_img":"2","mob_show_popup":"2","mob_show_video":"2","close_adv":"https:\/\/img.111cn.net\/uploads\/20240508\/663b20650801e.png","video_adv":"\/pc\/images\/pc-adv.mp4"};
</script>
<script src="/jspc/func.js" type="text/javascript"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-DSRRGRV1TL"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-DSRRGRV1TL');
</script>


<script src="/js/stat.js"></script>
</body>
</html>