|
|

楼主 |
发表于 2023-6-19 11:54
|
显示全部楼层
忙,没时间选图,旧图复用。帖子代码:
- <style>
- #mydiv {
- width: 1024px;
- height: 640px;
- background: #ccc url('https://638183.freep.cn/638183/t23/1/r3.jpg') no-repeat center / cover;
- box-shadow: 0 0 6px #000;
- pointer-events: none;
- z-index: 1;
- position: relative;
- margin: 30px auto;
- --clip: ''; --state: paused;
- }
- #mydiv::before, #mydiv::after {
- position: absolute;
- content: '';
- width: 200px;
- height: 200px;
- left: 180px;
- bottom: 50px;
- border-radius: 50%;
- pointer-events: auto;
- cursor: pointer;
- opacity: .75;
- }
- #mydiv::after {
- background: #FEFEFE;
- clip-path: var(--clip);
- animation: scale 6s infinite alternate linear var(--state);
- }
- #mydiv::before {
- background: url('https://638183.freep.cn/638183/t23/2/cat1b.gif') no-repeat center /cover;
- filter: hue-rotate(145deg);
- }
- @keyframes scale {
- 0% { transform: rotate(0deg) scale(1); }
- 50% { transform: rotate(360deg) scale(.8); }
- 100% { transform: rotate(-360deg) scale(1); }
- }
- </style>
- <div id="mydiv"></div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=523902194" autoplay="autoplay" loop="loop"></audio>
- <script>
- (function() {
- let clipBox = (xx,points,thick) => {
- let a = xx / 2, pointsAr = [`${xx}px 0, 0 0, 0 ${xx}px, ${xx}px ${xx}px, ${xx}px ${xx/2}px`];
- for(let i = 0; i <= points; i ++) {
- let hudu = Math.PI / 180 * 360 / points * i;
- let x1 = a + Math.cos(hudu) * (a - thick), y1 = a + Math.sin(hudu) * (a - thick);
- pointsAr.push(x1 + 'px ' + y1 + 'px');
- }
- pointsAr.push(`${xx}px ${xx/2}px`, `${xx}px 0px`);
- return `polygon(${pointsAr.join(',')})`;
- };
- mydiv.style.setProperty('--clip',clipBox(200,6,2));
- let mState = () => mydiv.style.setProperty('--state', aud.paused ? 'paused' : 'running');
- aud.addEventListener('play', mState, false);
- aud.addEventListener('pause', mState, false);
- mydiv.onclick = () => aud.paused ? aud.play() : aud.pause();
- })();
- </script>
复制代码
|
评分
-
| 参与人数 2 | 威望 +70 |
金钱 +140 |
经验 +70 |
收起
理由
|
老谟深虑
| + 20 |
+ 40 |
+ 20 |
赞一个! |
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|