首页 > 其他分享 >sticky,苹果官网文字从图片滚过,切换图片

sticky,苹果官网文字从图片滚过,切换图片

时间:2022-10-01 00:33:33浏览次数:58  
标签:-- 滚过 homepod sticky scrolled part homepodSection background 图片

 

 

  <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta http-equiv="X-UA-Compatible" content="IE=edge">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>Document</title>
    <style>       body {         margin: 0;         padding: 0;         font-family: Helvetica;       }
      .homepod-section {               }
      .other-section {         background-color: #eee;         height: 3000px;       }
      .description {         width: 490px;         padding: 80px 50px;         box-sizing: border-box;         background-color: rgba(0, 0, 0, .8);         border-radius: 20px;         text-align: center;         color: #fff;         margin: 0 auto 100vh;       }
      .description h3 {         font-size: 32px;         margin: 0;         padding: 0;       }
      .description p {         font-size: 18px;         margin: 12px 0 0;       }
      .homepod-container {         width: 100%;         height: 100vh;         position: sticky;         top: 0;         z-index: -1;       }
      .homepod {         width: 654px;         height: 825px;         position: absolute;         top: 50%;         left: 50%;         transform: translate(-50%, -50%);       }
      .homepod div {         width: inherit;         height: inherit;         background-size: contain;         background-position: center center;         position: absolute;         top: 0;         left: 0;       }
      .device {         background-image: url(https://assets.codepen.io/2002878/homepod.jpg);       }
      .part-1 {         background-image: url(https://assets.codepen.io/2002878/homepod_1.jpg);         opacity: var(--part-1);       }
      .part-2 {         background-image: url(https://assets.codepen.io/2002878/homepod_2.jpg);         opacity: var(--part-2);       }
      .part-3 {         background-image: url(https://assets.codepen.io/2002878/homepod_3.jpg);         opacity: var(--part-3);       }
      .part-4 {         background-image: url(https://assets.codepen.io/2002878/homepod_4.jpg);         opacity: var(--part-4);       }
      .ending {         background-image: url(https://assets.codepen.io/2002878/homepod.jpg);         opacity: var(--ending);       }
      .description-container {         padding-bottom: 100vh;       }
      .description:last-child {         margin-bottom: 0;       }
        </style>
</head> <body>

  <section class="homepod-section">     <div class="homepod-container">       <div class="homepod">         <div class="device"></div>         <div class="part-1"></div>         <div class="part-2"></div>         <div class="part-3"></div>         <div class="part-4"></div>         <div class="ending"></div>       </div>     </div>     <div class="description-container">       <div class="description">         <h3>Deep bass with range you can feel.</h3>         <p>The Apple-designed high-excursion woofer is positioned at the top of the speaker facing upward, creating a wide range of deep bass that surpasses any traditional speaker. A six-microphone array, along with an internal bass-EQ microphone, analyzes and compensates for the effect of the room on the bass response, providing rich, consistent sound. And a powerful motor drives the diaphragm a remarkable 20 mm, so the bass shines through even when the volume is low.</p>       </div>         <div class="description">         <h3>Far and away an incredible listener.</h3>         <p>Six microphones positioned around HomePod allow it to pick up all the sound in a room. When you say “Hey Siri,” advanced signal processing, together with echo and noise cancellation, allows HomePod to hear you without the need to raise your voice — even if you’re across the room with loud music playing. After HomePod recognizes the words “Hey Siri,” what you say is encrypted and sent anonymously to Apple servers without being tied to your Apple ID.</p>       </div>         <div class="description">         <h3>High-fidelity audio that’s all around you.</h3>         <p>A custom-designed array of seven beamforming tweeters, each with its own amplifier, creates tremendous directional control. Placed around the base and using a folded-horn design, they send the flow of music toward the center and then out the bottom in a 360-degree pattern, resulting in an all-encompassing sense of space. This virtually eliminates early table reflections and allows for consistent high-definition sound.</p>       </div>         <div class="description">         <h3>The biggest brain ever in a speaker.</h3>         <p>An Apple-designed A8 chip orchestrates all the remarkable audio innovations inside HomePod. Like advanced signal processing so Siri can hear you over the music. Real-time studio-level processing that maximizes the bass while minimizing distortion. Buffering that’s even faster than real time. And upmixing of both direct and ambient audio. You get amazing sound, every single time.</p>       </div>         <div class="description">         <h3>Designed to be seen and heard.</h3>         <p>HomePod is wrapped in a seamless mesh fabric designed for aesthetics and acoustic performance. Available in white and space gray, it’s gorgeous from every angle — yet virtually transparent to the sound waves passing through it.</p>       </div>     </div>   </section>   <section class="other-section"></section>


    <script>
      const homepodSection = document.querySelector('.homepod-section')
      const sectionHeight = homepodSection.getBoundingClientRect().height
      const html = document.documentElement
      document.addEventListener('scroll', (e) => {         let scrolled = html.scrollTop / (sectionHeight - html.clientHeight)         console.log(`scrolled: ${scrolled}`)                 homepodSection.style.setProperty('--part-1', calculateOpacity(0.05, 0.15, scrolled))         homepodSection.style.setProperty('--part-2', calculateOpacity(0.19, 0.23, scrolled))         homepodSection.style.setProperty('--part-3', calculateOpacity(0.35, 0.40, scrolled))         homepodSection.style.setProperty('--part-4', calculateOpacity(0.58, 0.63, scrolled))         homepodSection.style.setProperty('--ending', calculateOpacity(0.80, 0.85, scrolled))               })
      function calculateOpacity(start, end, percent) {         if (percent - start < 0) return 0         if (percent - end > 0) return 1                 return (percent - start) / (end - start)       }


    </script>
</body> </html>

标签:--,滚过,homepod,sticky,scrolled,part,homepodSection,background,图片
From: https://www.cnblogs.com/xushan03/p/16746607.html

相关文章

  • 浏览器必备的上网工具,同样也是收藏党必备工具, 网页图片收藏工具,可以收藏全网的网页图
    浏览器必备的上网工具,同样也是收藏党必备工具,网页图片收藏工具,可以收藏全网的网页图片,无需下载到本地了,太方便了工具名称:BdTab新标签页插件,支持图片收藏......
  • v-viewer图片预览插件使用
    链接:https://www.jianshu.com/p/1fd3b4e6911c今天介绍一款用于图片浏览的Vue组件,支持旋转、缩放、翻转等操作,它是基于viewer.js做的二次开发,我感觉用起来挺方便的,Github......
  • vite引入图片
    vite引入图片出现的问题-不能够页面<template><div><div><imgclass="imgsize"sr="../../assets/img/xiaoxiannv.png"/>......
  • HTML08.图片元素
    图片元素img元素单词缩写:image缩写,空元素src属性:source表示资源,用于指定图像文件的路径和文件名,他是img标签的必须属性。站外属性:就直接右键保存图片地址然后复......
  • 图片降噪软件:Topaz DeNoise AI (图像处理)
    TopazDeNoiseAI是一款好用且专业的图片降噪软件。如果你有噪点的相片,可以通过AI智能的方式来处理掉噪点,让照片的噪点降到最低。有了TopazDeNoiseAI处理图片更方便,更简......
  • 获取图片并预览
    环境介绍:代码工具:VisualStudio2022开发框架:.netformwork4.7.2开发须知当前我所了解的有.netcore以及.netformwork两种框架.netformwork:这个是微软专用......
  • 分享一个Vue实现图片水平瀑布流的插件
    这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助一.需求来源今天碰到了一个需求,需要在页面里,用水平瀑布流的方式,将一些图片进行加载,这让我突然想起我很久......
  • js 根据 base64 和图片 宽高 ,截取参数 裁减图片 并且返回 处理后的 base64 图片
    参考来源https://stackoverflow.com/questions/31193418/html5-canvas-todataurl-returns-blankhttps://www.geeksforgeeks.org/how-to-crop-images-in-reactjs/https:/......
  • Ant Design Vue 在表格中插入图片
    这两天一直在用Antdv做一些小demo,今天在做表格的时候想在表格中插入图片,简单翻了下文档和国内的博客,发现所有的方法竟然都不好使,最后还是在官网的示例代码中看到相关的部......
  • 直播平台源代码,uni-app上传图片方法封装
    直播平台源代码,uni-app上传图片方法封装 functionchooseImg(count,success){console.log(count)uni.chooseImage({count:count,success:res=>{//console.log(re......