div+css布局实现文字环绕成太阳形状代码

代码语言:html

所属分类:布局界面

代码描述:div+css布局实现文字环绕成太阳形状代码

代码标签: div css 布局 文字 环绕 太阳 形状 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
<style>
@property --rotate {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}
@property --delayed-rotate {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}
@keyframes scrollAnim {
  to {
    --rotate: 1;
    --delayed-rotate: 1;
  }
}
:root {
  --circle-size: 30vmin;
  --spacing: 3vmin;
  --font-size: 5vmin;
  --ease-speed: 50ms;
}

body {
  height: 500vh;
  margin: 0;
  padding: 0;
  font-family: serif;
  font-size: var(--font-size);
  background-color: #EDE8E4;
  color: #222;
  animation: scrollAnim linear;
  animation-timeline: scroll(nearest block);
}

ul {
  position: fixed;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  display: block;
  width: var(--circle-size);
  height: var(--circle-size);
  margin: 0;
  padding: 0;
  list-style: none;
  border-radius: 50%;
  transform: rotate(calc(var(--rotate) * 360deg));
}

li {
  position: absolute;
  top: 50%;
  left: 50%;
  line-height: 0;
  transform-origin: 0 0;
  text-wrap: nowrap;
}
li:nth-child(1) {
  rotate: calc(18deg);
}
li:nth-child(2) {
  rotate: calc(36deg);
}
li:nth-child(3) {
  rotate: calc(54deg);
}
li:nth-child(4) {
  rotate: calc(72deg);
}
li:nth-child(5) {
  rotate: calc(90deg);
}
li:nth-child(6) {
  rotate: calc(108deg);
}
li:nth-child(7) {
  rotate: calc(126deg);
}
li:nth-child(8) {
  rotate: calc(144deg);
}
li:nth-child(9) {
  rotate: calc(162deg);
}
li:nth-child(10) {
  rotate: calc(180deg);
}
li:nth-child(11) {
  rotate: calc(198deg);
}
li:nth-child(12) {
  rotate: calc(216deg);
}
li:nth-child(13) {
  rotate: calc(234deg);
}
li:nth-child(14) {
  rotate: calc(252deg);
}
li:nth-child(15) {
  rotate: calc(270deg);
}
li:nth-child(16) {
  rotate: calc(288deg);
}
li:nth-child(17) {
  rotate: calc(306deg);
}
li:nth-child(18) {
  rotate: calc(324deg);
}
li:nth-child(19) {
  rotate: calc(342deg);
}
li:nth-child(20) {
  rotate: calc(360deg);
}
li span {
  --rotate-velocity: calc(var(--rotate) - var(--delayed-rotate));
  --rotate-velocity-abs: abs(var(--rotate-velocity));
  --rotate-spacing: calc(var(--spacing) * -4 * var(--rotate-velocity));
  --x: calc(var(--circle-size) / 2 + var(--rotate-spacing));
  --y: calc(10px * var(--rotate-velocity));
  --r: calc(90deg * var(--rotate-velocity));
  display: inline-block;
  transform: translate(var(--x), var(--y)) rotate(var(--r, 0deg));
}
li span:nth-child(1) {
  --y: calc((1 * -20px) * var(--rotate-velocity));
  transform-origin: var(--x) 0;
  transition: --delayed-rotate calc(var(--ease-speed, 100ms) * 0) ease-out;
}
li span:nth-child(2) {
  --y:.........完整代码请登录后点击上方下载按钮下载查看

网友评论0