人民医院前端

index.html 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>lime-circle</title>
  8. <style>
  9. html,body{
  10. padding: 0;
  11. margin: 0;
  12. width: 100%;
  13. height: 100%;
  14. }
  15. .lime-circle {
  16. position: relative;
  17. width: 100%;
  18. height: 100%;
  19. }
  20. .lime-circle__trail,.lime-circle__stroke {
  21. position: absolute;
  22. width: 100%;
  23. height: 100%;
  24. border-radius: 50%;
  25. }
  26. .lime-circle__inner{
  27. position: absolute;
  28. left: 0;
  29. right: 0;
  30. top: 0;
  31. bottom: 0;
  32. align-items: center;
  33. justify-content: center;
  34. display: flex;
  35. }
  36. .is-round .lime-circle__trail .cap{
  37. position: absolute;
  38. display: block;
  39. width: var(--l-trail-cap-size, 6px);
  40. height: var(--l-trail-cap-size, 6px);
  41. background-color: var(--l-trail-cap-color, #ddd);
  42. z-index: 10;
  43. border-radius: 50%;
  44. }
  45. .is-round .lime-circle__trail .cap.start {
  46. left: var(--l-trail-cap-start-x, 14%);
  47. top: var(--l-trail-cap-start-y, 81%);
  48. }
  49. .is-round .lime-circle__trail .cap.end {
  50. left: var(--l-trail-cap-end-x, 14%);
  51. top: var(--l-trail-cap-end-y, 81%);
  52. }
  53. .is-round .lime-circle__stroke .cap{
  54. position: absolute;
  55. display: block;
  56. width: var(--l-stroke-cap-size, 6px);
  57. height: var(--l-stroke-cap-size, 6px);
  58. background-color: var(--l-stroke-cap-start-color, #ddd);
  59. border-radius: 50%;
  60. transition: opacity 350ms ease-out;
  61. opacity: var(--l-stroke-cap-opacity, 0);
  62. }
  63. .is-round .lime-circle__stroke .cap.start {
  64. left: var(--l-stroke-cap-start-x, 14%);
  65. top: var(--l-stroke-cap-start-y, 81%);
  66. background-color: var(--l-stroke-cap-start-color, #ddd);
  67. }
  68. .is-round .lime-circle__stroke .cap.end {
  69. left: var(--l-stroke-cap-end-x, 14%);
  70. top: var(--l-stroke-cap-end-y, 81%);
  71. z-index: -1;
  72. background-color: var(--l-stroke-cap-end-color, #ddd);
  73. }
  74. .clockwise .lime-circle__inner{
  75. transform: scale(-1,1);
  76. }
  77. </style>
  78. </head>
  79. <body>
  80. <div class="lime-circle">
  81. <div class="lime-circle__trail">
  82. <i class="cap start"></i>
  83. <i class="cap end"></i>
  84. </div>
  85. <div class="lime-circle__stroke">
  86. <i class="cap start"></i>
  87. <i class="cap end"></i>
  88. </div>
  89. </div>
  90. <script>
  91. function toStyle(obj) {
  92. let str = ''
  93. for (const key in obj) {
  94. str += `${key}:${obj[key]};`
  95. }
  96. return str
  97. }
  98. function setStyle(type, style) {
  99. if(!type) {
  100. const trail = document.querySelector('.lime-circle__trail')
  101. trail.style = toStyle(style)
  102. } else {
  103. const stroke = document.querySelector('.lime-circle__stroke')
  104. stroke.style = toStyle(style)
  105. }
  106. // trail.style.background = 'red'
  107. // trail.setAttribute()
  108. // trail.style.setProperty('--color','#cd0000');
  109. }
  110. // type 0删除 1增加
  111. function setClass(target, className, type) {
  112. const box = document.querySelector(target)
  113. if(!type) {
  114. box.classList.remove(className)
  115. } else {
  116. box.classList.add(className)
  117. }
  118. }
  119. setStyle(0,
  120. {
  121. "mask": "radial-gradient(transparent 65.5px, #000 66px)",
  122. "-webkit-mask": "radial-gradient(transparent 65.5px, #000 66px)",
  123. "background": "conic-gradient(from 225deg, #ddd 0%, #ddd 75%, transparent 75%, transparent 100%)",
  124. "--l-trail-cap-start-x": "20.209632098128225px",
  125. "--l-trail-cap-start-y": "117.79036790187178px",
  126. "--l-trail-cap-end-x": "117.79036790187178px",
  127. "--l-trail-cap-end-y": "117.79036790187178px",
  128. "--l-trail-cap-color": "#ddd",
  129. "--l-trail-cap-size": "6px"
  130. }
  131. )
  132. // setStyle(1,
  133. // {
  134. // "mask": "radial-gradient(transparent 65.5px, #000 66px)",
  135. // "-webkit-mask": "radial-gradient(transparent 65.5px, #000 66px)",
  136. // "background": "conic-gradient(from 225deg, transparent 0%,#0000ff 0%,#ff0000 calc(var(--l-percent) * 1),transparent var(--l-percent), transparent 75%)",
  137. // "--l-percent": "75%",
  138. // "--l-stroke-cap-start-color": "#0000ff",
  139. // "--l-stroke-cap-end-color": "#ff0000",
  140. // "--l-stroke-cap-start-x": "20.209632098128225px",
  141. // "--l-stroke-cap-start-y": "117.79036790187178px",
  142. // "--l-stroke-cap-end-x": "117.79036790187179px",
  143. // "--l-stroke-cap-end-y": "117.79036790187178px",
  144. // "--l-stroke-cap-size": "6px"
  145. // }
  146. // )
  147. </script>
  148. </body>
  149. </html>