zoukankan      html  css  js  c++  java
  • background-attachment:fixed应用

    设置为fixed属性,背景相对于屏幕窗口固定,然后如果有一张全屏的图片,再来一张全屏的图片,就可以看到与平时滚动屏幕不同的切换图片。代码
    CSS部分:

    html, body,.content{
            height: 100%;
    }
    h2, body { margin: 0;}
    .fixed-bg { 
            position: relative;
            background-size: cover;
            background-attachment: fixed;
            height: 100%;
            background-position: center center;
    }
    .bg-1 { 
             background-image: url("images/cd-background-1.jpg");
    }
    .container { 
            padding: 23% 1%;
               background-color: #C7ABAB; 
               height: 100%;
    }
    .bg-2 { 
            background-image: url("images/cd-background-2.jpg");
    }

    HTML部分:

    <div class="main content">
            <div class="fixed-bg bg-1">
                    <h2>此处是图片</h2>
            </div>
            <div class="fixed-bg bg-2">
                    <h2>又一张图片</h2>
            </div>
    </div>

    由此可以想到:如果图片之间加上内容 ,就会是比较新鲜的滚动方式:

    <!DOCTYPE html>
    <html lang="en">
    <head>
            <meta charset="UTF-8">
            <title>Document</title>
            <style type="text/css">
            html, body,.content{
                    height: 100%;
            }
            h2, body { margin: 0;}
            .fixed-bg { 
                    position: relative;
                    background-size: cover;
                    background-attachment: fixed;
                    height: 100%;
                     background-position: center center;
            }
            .bg-1 { 
                     background-image: url("images/cd-background-1.jpg");
            }
            .container { padding: 23% 1%;
                        background-color: #C7ABAB; 
                        height: 100%;}
            .bg-2 { 
                     background-image: url("images/cd-background-2.jpg");
            }
    
            </style>
            
    
    
    </head>
    <body>
            <div class="main content">
                    <div class="fixed-bg bg-1">
                            <h2>此处是图片</h2>
                    </div>
                    <div class="scrolling-bg"> 
                            <div class="container">
                                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore incidunt suscipit similique, dolor corrupti cumque qui consectetur autem laborum fuga quas ipsam doloribus sequi, mollitia, repellendus sapiente repudiandae labore rerum amet culpa inventore, modi non. Illo quod repellendus alias? Cum rem doloremque adipisci accusantium? Saepe, necessitatibus!</p>
                            </div>
                    </div>
    
    
                    <div class="fixed-bg bg-2">
                            <h2>又一张图片</h2>
                    </div>
                    <div class="scrolling-bg"> 
                            <div class="container">
                                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore incidunt suscipit similique, dolor corrupti cumque qui consectetur autem laborum fuga quas ipsam doloribus sequi, mollitia, repellendus sapiente repudiandae labore rerum amet culpa inventore, modi non. Illo quod repellendus alias? Cum rem doloremque adipisci accusantium? Saepe, necessitatibus!</p>
                            </div>
                    </div>
            </div>
    </body>
    </html>
  • 相关阅读:
    MYSQL查询表信息
    认识WCF
    asp.net mvc 模型验证注解,表单提交
    asp.net mvc 防止开放重定向
    asp.net webForm登录授权
    C# 压缩文件与字节互转
    C#将字节流加密解密
    获取数据库表详细信息、存储过程、视图、的sql
    Mvc4学习笔记一(Ajax.ActionLink)
    java开发之提高java和mysql代码性能和质量
  • 原文地址:https://www.cnblogs.com/samtrybest/p/5071210.html
Copyright © 2011-2022 走看看