參考外面網站練習的視差滾動,但卻跑不出效果,想問哪邊錯了qq
參考網站:https://www.tellustek.com/web-design/156-parallax-scrolling?fbclid=IwAR06R0LHd4jevsCHjvAlCRd-5gbNnz1jUB4ZeNYw42S5tJhQzxtsYV9ZNIc
position:fixed;是看網站裡小編打的程式碼跟著打的,想問為什麼要定住? 如果只是要浮動的效果不能用relative嗎
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="jquery-3.4.1.min.js"></script>
<script src="jquery.stellar.min.js"></script>
<script>
$(document).ready(function () {
$.stellar();
});
</script>
<style type="text/css">
.box1{color:#FFFFFF;font-size:40px;top:300px;left:500px;position:fixed;}
.allheight{height:1300px;background-color:#30345F}
</style>
</head>
<body>
<div class="allheight">
<div class="box1" data-stellar-ratio="0.2">words</div>
</div>
</body>
</html>