• 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>
  • 相关阅读:
    SpringBoot学习
    Matlab立体标定mat转换成Opencv的CvMat
    由lib引发的血案(opencv找不函数问题)
    C# 使用Epplus导出Excel [4]:合并指定行
    C# 使用Epplus导出Excel [3]:合并列连续相同数据
    C# 使用Epplus导出Excel [2]:导出动态列数据
    C# 使用Epplus导出Excel [1]:导出固定列数据
    C# Excel常用控件总结
    C# IsNullOrEmpty与IsNullOrWhiteSpace
    C# 读App.config配置文件[2]: .Net Core框架
  • 原文地址:https://www.cnblogs.com/samtrybest/p/5071210.html
Copyright © 2020-2023  润新知