zoukankan      html  css  js  c++  java
  • css实现全图滚动

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <title>css实现全图滚动</title>
        <style>
          * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
          }
          .container {
             100%;
            height: 100%;
    
            /*使用css实现全图滚动*/
            overflow-y: scroll;
            scroll-behavior: smooth;
            scroll-snap-type: y mandatory;
          }
          body {
            height: 100vh;
            font-family: Arial, Helvetica, sans-serif;
            background: #333;
            line-height: 1.6;
            color: #fff;
            overflow: hidden;
          }
          .navbar {
            position: fixed;
            top: 0;
            z-index: 1;
             100%;
            height: 60px;
            background: rgba(0, 0, 0, 0.7);
          }
          .navbar ul {
            display: flex;
            list-style: none;
             100%;
            justify-content: center;
          }
          .navbar ul li {
            margin: 0 1rem;
            padding: 1rem;
          }
          .navbar ul li a {
            text-decoration: none;
            color: #f4f4f4;
          }
          .navbar ul li a:hover {
            color: skyblue;
          }
          section {
             100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            text-align: center;
    
            scroll-snap-align: center;
          }
          section h1 {
            font-size: 4rem;
          }
          section p {
            font-size: 1.5rem;
          }
          #home {
            background: url("https://images.pexels.com/photos/34140/pexels-photo.jpg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940")
              no-repeat center center/cover;
          }
          #about {
            background: url("https://images.pexels.com/photos/1591060/pexels-photo-1591060.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940")
              no-repeat center center/cover;
          }
          #service {
            background: url("https://images.pexels.com/photos/267371/pexels-photo-267371.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940")
              no-repeat center center/cover;
          }
          #contact {
            background: url("https://images.pexels.com/photos/276259/pexels-photo-276259.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940")
              no-repeat center center/cover;
          }
        </style>
      </head>
      <body>
        <div class="container">
          <nav class="navbar">
            <ul>
              <li><a href="#home">主页</a></li>
              <li><a href="#about">关于我们</a></li>
              <li><a href="#service">服务</a></li>
              <li><a href="#contact">联系我们</a></li>
            </ul>
          </nav>
          <section id="home">
            <h1>主页</h1>
            <p class="lead">
              Lorem ipsum dolor sit amet consectetur adipisicing elit. Facilis
              laboriosam eaque ipsa optio, modi dolor id, ea assumenda quia facere
              iste debitis harum perspiciatis cupiditate adipisci esse itaque et
              labore.
            </p>
          </section>
          <section id="about">
            <h1>关于我们</h1>
            <p class="lead">
              Lorem ipsum dolor sit amet consectetur adipisicing elit. Facilis
              laboriosam eaque ipsa optio, modi dolor id, ea assumenda quia facere
              iste debitis harum perspiciatis cupiditate adipisci esse itaque et
              labore.
            </p>
          </section>
          <section id="service">
            <h1>服务</h1>
            <p class="lead">
              Lorem ipsum dolor sit amet consectetur adipisicing elit. Facilis
              laboriosam eaque ipsa optio, modi dolor id, ea assumenda quia facere
              iste debitis harum perspiciatis cupiditate adipisci esse itaque et
              labore.
            </p>
          </section>
          <section id="contact">
            <h1>联系我们</h1>
            <p class="lead">
              Lorem ipsum dolor sit amet consectetur adipisicing elit. Facilis
              laboriosam eaque ipsa optio, modi dolor id, ea assumenda quia facere
              iste debitis harum perspiciatis cupiditate adipisci esse itaque et
              labore.
            </p>
          </section>
        </div>
      </body>
    </html>
    

      

  • 相关阅读:
    Android Fragment(一)
    Android github上的好的开源项目汇总
    Android ScrollView 嵌套ListView的替代方案
    Android cannot be cast to android.app.Fragment
    js css加时间戳
    WPF无边框实现拖动效果
    分析器错误消息: 未能加载类型
    微信红包功能(含示例demo)
    ABP缓存示例
    微信白名单配置与检验
  • 原文地址:https://www.cnblogs.com/m-yk/p/10819350.html
Copyright © 2011-2022 走看看