html - CSS Parallax overflow-y:scroll 让它消失
问题描述
我已经成功制作了纯 CSS视差,这很难!^^
但我有一个问题。
要进行视差,我们必须overflow-y : scroll
适当地从上到下滚动具有透视适当性的块。
问题是它迫使我添加一个丑陋的滚动条,我怎么能删除它?
谢谢 !:)
这是我的片段:
*{box-sizing: border-box;}
body{
margin: 0;
}
.parent{
perspective: 200px;
perspective-origin: bottom right;
height: 100vh;
overflow-y: scroll;
}
.parent:before{
content:'';
position: absolute;
background: linear-gradient(white, #A00000);
height: 300vh;
width: 100vw;
}
section{
height: 50vh;
transform-style: preserve-3d;
}
span{
background: url('https://image.flaticon.com/icons/png/512/248/248983.png') no-repeat;
height: 100%;
width: 100%;
position: absolute;
}
.firstChild{
transform: translateZ(-200px);
}
.secondChild{
background: url('https://image.flaticon.com/icons/png/512/248/248983.png') no-repeat;
transform: translateZ(-100px) ;
}
.secondChild{
transform: translateZ(-300px) ;
}
<!DOCTYPE html>
<html>
<head>
<title>title</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1> My website is not awesome.</h1>
<div class="parent">
<section><span class="firstChild"></span></section>
<section><span class="secondChild"></span></section>
<section><span class="thirdChild"></span></section>
</div>
</body>
</html>
解决方案
将此添加到您的 css 以使滚动条不可见:
.parent::-webkit-scrollbar {
display: none;
}
推荐阅读
- sql - BigQuery - 正则表达式匹配已知字符串后的 8 位数
- ios - 由于 manifest.plist,IOS App Distribution 部署 In House 安装失败
- elasticsearch - 如何为从相同文件节拍到logstash的不同日志设置不同的索引名称
- angular - 错误:wasm 的异步和同步获取均失败
- javascript - 如何使用node js从mysql数据库中获取值
- javascript - select2.js 未显示结果,如 Django 示例
- shell - 如何获取pid并处理最后一个shell命令的现有代码
- javascript - 在 javascript 中使用 for-loop 为音频文件分配不同的来源
- typescript - 切换按钮计数器
- javascript - 我应该如何在最后一行数据之后添加行(没有标题)(不覆盖“Master_db”中的任何内容)