動畫文字我跟著學的教程是:https://www.youtube.com/watch? v = 4p bgtye 0 MGS。
動畫文本可以正確顯示和工作,但是,當動畫結束時,文本會滑到屏幕右側。在線查看后,看起來我需要使用display:flex,但是,使用它會使我的自定義光標實現無法工作。對于頁面的大部分內容,自定義光標不會保持為png圖像。有沒有其他方法可以解決這個問題?
這是我的HTML頁面:
<!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>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1 data-text=" Hi! I'm Julie :) "> Hi! I'm Julie :) </h1>
<div class="main-wrapper">
<div class="season winter" data-background="#2b1055">Winter</div>
<div class="season summer" data-background="#5988e2">Summer</div>
<div class="season spring" data-background="#7cdea1">Spring</div>
<div class="season autumn" data-background="#f79762">Autumn</div>
</div>
<div class="wrapper">
<div>
<img id="earth" src="img/earth.png" alt="scroll">
</div>
</div>
<script src="app.js"></script>
</body>
</html>
CSS:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body {
transition: background 1s ease-in-out;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
}
h1 {
align-items: center;
position: relative;
font-size: 6em;
color: transparent;
margin: 40px;
cursor: url('img/winter-cursor.png'), auto;
}
h1::before {
content: attr(data-text);
position: absolute;
color: white;
width: 350px;
overflow: hidden;
white-space: nowrap;
border-right: 4px solid #fff;
animation: animate 8s linear infinite;
filter: drop-shadow(0 0 20px #fff);
}
@keyframes animate {
0%, 10%, 100% {
width: 0;
}
70%, 90% {
width: 100%;
}
}
.season {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100vh;
color: #fff;
font-family: sans-serif;
font-size: 72px;
font-weight: 600;
text-transform: uppercase;
}
.winter {
cursor: url('img/winter-cursor.png'), auto;
}
.summer {
cursor: url('img/summer-cursor.png'), auto;
}
.spring {
cursor: url('img/spring-cursor.png'), auto;
}
.autumn {
cursor: url('img/autumn-cursor.png'), auto;
}
.wrapper {
top: 120%;
left: 50%;
transform: translate(-50%, -50%);
position: fixed;
cursor: url(img/earth-cursor.png), auto;
}
#earth {
width: 800px;
height: 800px;
cursor: url(img/earth-cursor.png), auto;
}