|
|

楼主 |
发表于 2024-9-10 15:02
|
显示全部楼层
第二个作业
<style>
.tiezi {
margin: 30px 0 30px calc(50% - 731px);
width: 1280px;
height: 720px;
box-sizing: border-box;
border: 3px solid;
border-image: linear-gradient(to top right, #d1e4e9, #bed9e1, #78a9c3, #95b9c2) 3 3;
background: url('https://p.upyun.com/demo/tmp/ZQSIZuuI.webp') no-repeat center/cover;
z-index: 1;
pointer-events: none;
position: relative;
}
#mypic {
position: absolute; /* 绝对定位 */
left: 20px; /* 左边位置*/
top: 580px; /* 上边位置 */
width: 120px; /* 宽度 */
height: 120px; /* 高度 */
/* animation简化语法 :动画名称+运动周期时长+缓动形式+运行次数 */
animation: rot 58s linear 3;
}
/* 设计CSS关键帧动画 */
@keyframes rot {
from { transform:translate(0px); } /* 从 0 度开始旋转 */
to { transform:translate(1180px); } /* 到 360 度即一圈完成一个旋转周期 */
}
</style>
<div class="tiezi" id="tzi">
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=2080659326" autoplay loop></audio>
<img id="mypic" alt="" src="https://p.upyun.com/demo/tmp/V6drffz0.webp" />
</div>
<script>
aud.ontimeupdate = () => tzi.style.setProperty('--hue', Math.floor(Math.random() * 80) + 'deg');
tzi.onclick = () => aud.paused ? aud.play() : aud.pause();
</script> |
|