加载效果
代码
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>加载效果title>
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css"
integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js"
integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd"
crossorigin="anonymous">script>
<style>
* {
margin: 0;
padding: 0;
}
body {
background: #2980b9;
}
.loading {
height: 40px;
position: absolute;
top: 50%;
left: 50%;
display: flex;
transform: translate(-50%, -50%);
align-items: center;
}
.object {
width: 6px;
height: 40px;
background: white;
margin: 0 3px;
border-radius: 10px;
animation: loading 0.8s infinite;
animation-play-state: paused;
}
.xyBtn {
position: absolute;
top: 60%;
left: 50%;
transform: translate(-40%, -50%);
}
.object:nth-child(2) {
animation-delay: 0.1s;
}
.object:nth-child(3) {
animation-delay: 0.2s;
}
.object:nth-child(4) {
animation-delay: 0.3s;
}
.object:nth-child(5) {
animation-delay: 0.4s;
}
.object:nth-child(6) {
animation-delay: 0.5s;
}
.object:nth-child(7) {
animation-delay: 0.6s;
}
.object:nth-child(8) {
animation-delay: 0.7s;
}
@keyframes loading {
0% {
height: 0;
}
50% {
height: 40px;
}
100% {
height: 0;
}
}
.animate {
animation-play-state: running;
}
.paused {
animation-play-state: paused;
}
style>
head>
<body>
<div class="loading">
<div class="object">div>
<div class="object">div>
<div class="object">div>
<div class="object">div>
<div class="object">div>
<div class="object">div>
<div class="object">div>
<div class="object">div>
div>
<button type="button" class="btn btn-info xyBtn" id="toggleButton">开始动画button>
<script>
var toggleButton = document.getElementById("toggleButton");
var objectElements = document.getElementsByClassName("object");
var animationState = false;
toggleButton.addEventListener("click", function () {
animationState = !animationState;
if (animationState) {
for (var i = 0; i < objectElements.length; i++) {
objectElements[i].classList.add("animate");
objectElements[i].classList.remove("paused");
}
toggleButton.textContent = "暂停动画";
} else {
for (var i = 0; i < objectElements.length; i++) {
objectElements[i].classList.add("paused");
objectElements[i].classList.remove("animate");
}
toggleButton.textContent = "开始动画";
}
});
script>
body>
html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
创意视频球特效
代码
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>创意视频球特效title>
<style>
* {
margin: 0;
padding: 0;
}
body {
overflow: hidden;
}
section {
position: absolute;
top: -100px;
left: -100px;
right: -100px;
bottom: -100px;
display: flex;
justify-content: center;
align-items: center;
}
section video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
filter: blur(35px);
}
section .sphere {
position: relative;
width: 600px;
height: 600px;
border-radius: 50%;
z-index: 10;
}
section .sphere::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 100;
border-radius: 50%;
box-shadow: inset 0 100px 100px rgba(255, 255, 255, 0.5),
inset 0 -100px 100px rgba(0, 0, 0, 1),
inset 0 0 100px rgba(0, 0, 0, 1);
}
section .sphere::after {
content: "";
position: absolute;
top: 550px;
left: -50px;
width: 700px;
height: 100px;
z-index: -1;
border-radius: 50%;
background: black;
background: radial-gradient(black, transparent, transparent);
}
section .sphere video {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
object-fit: cover;
border-radius: 50%;
filter: blur(0);
}
section .controls {
position: absolute;
bottom: 100px;
left: 50%;
transform: translateX(-50%);
display: flex;
align-items: center;
}
section .controls button {
background: none;
border: none;
outline: none;
cursor: pointer;
color: white;
font-size: 20px;
margin-right: 10px;
font-family: 'Times New Roman', Times, serif;
}
section .controls input[type="range"] {
width: 800px;
margin-right: 10px;
}
section .controls span {
color: white;
font-size: 18px;
font-family: 'Times New Roman', Times, serif;
}
style>
head>
<body>
<section>
<video id="backgroundVideo" src="../Videos/1-“挑 战 B 站 画 质 上 限”-4K 超清-AVC.mp4">video>
<div class="sphere">
<video id="sphereVideo" src="../Videos/1-“挑 战 B 站 画 质 上 限”-4K 超清-AVC.mp4">video>
div>
<div class="controls">
<button id="playPauseButton">播放button>
<input type="range" id="progressBar" min="0" step="0.001">
<span id="currentTime">00:00span>
<span>/span>
<span id="duration">00:00span>
div>
section>
<script>
document.addEventListener("DOMContentLoaded", function () {
var backgroundVideo = document.getElementById("backgroundVideo");
var sphereVideo = document.getElementById("sphereVideo");
var playPauseButton = document.getElementById("playPauseButton");
var progressBar = document.getElementById("progressBar");
var currentTime = document.getElementById("currentTime");
var duration = document.getElementById("duration");
backgroundVideo.pause();
sphereVideo.pause();
progressBar.value = 0;
playPauseButton.addEventListener("click", function () {
if (backgroundVideo.paused) {
backgroundVideo.play();
sphereVideo.play();
playPauseButton.textContent = "暂停";
} else {
backgroundVideo.pause();
sphereVideo.pause();
playPauseButton.textContent = "播放";
}
});
backgroundVideo.addEventListener("timeupdate", function () {
var progress = (backgroundVideo.currentTime / backgroundVideo.duration) * 100;
progressBar.value = progress;
currentTime.textContent = formatTime(backgroundVideo.currentTime);
});
progressBar.addEventListener("input", function () {
var progressTime = (progressBar.value / 100) * backgroundVideo.duration;
backgroundVideo.currentTime = progressTime;
sphereVideo.currentTime = progressTime;
currentTime.textContent = formatTime(progressTime);
});
function formatTime(time) {
var minutes = Math.floor(time / 60);
var seconds = Math.floor(time % 60);
return (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds;
}
backgroundVideo.addEventListener("loadedmetadata", function () {
duration.textContent = formatTime(backgroundVideo.duration);
});
backgroundVideo.addEventListener("ended", function () {
playPauseButton.textContent = "播放";
progressBar.value = 0;
currentTime.textContent = "00:00";
});
});
script>
body>
html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229