|
|

楼主 |
发表于 2023-6-25 13:13
|
显示全部楼层
框架代码
- <style>
- #mydiv {
- margin: 20px auto;
- width: 700px;
- min-height: 400px;
- border-radius: 16px;
- border: 3px dotted purple;
- background: #eee;
- padding: 20px;
- position: relative;
- --state: paused;
- }
- #mydiv::before, #mydiv::after {
- position: absolute;
- content: '';
- }
- #mydiv::before {
- width: 50px;
- height: 50px;
- left: calc(50% - 25px);
- bottom: 10px;
- border-radius: 50%;
- background: conic-gradient(teal,rebeccapurple,purple,tan);
- -webkit-mask: radial-gradient(transparent 3px, red 0);
- box-shadow: 0 0 4px gray;
- cursor: pointer;
- animation: rot 6s infinite linear var(--state);
- }
- #mydiv::after {
- content: '帖子标题';
- left: 50%;
- top: -22px;
- transform: translate(-50%);
- background: linear-gradient(purple,rebeccapurple);
- clip-path: polygon(5% 0%, 95% 0%, 100% 50%, 95% 100%, 5% 100%, 0% 50%);
- font: bold 24px/40px sans-serif;
- text-shadow: 1px 1px 2px #000;
- color: #ccc;
- padding: 0 40px;
- }
- @keyframes rot { to { transform: rotate(360deg); } }
- </style>
- <div id="mydiv">
- <p>Hello HUACHAO</p>
- </div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1893183597" autoplay="autoplay" loop="loop"></audio>
- <script>
- (function () {
- 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>
复制代码
|
|