Advertisement
Guest User

Progress Bars

a guest
Oct 16th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.98 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. /*===== Not The CSS :P =====*/
  6. @import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700');
  7. h1 {
  8. font-family: 'Open Sans';
  9. color: rgb(255, 255, 255);
  10. text-align: center;
  11. margin: 50px 0 -80px;
  12. }
  13. a {
  14. font-family: 'Open Sans';
  15. color: rgb(0, 0, 0);
  16. margin: 50px 0 -80px;
  17. text-align: center;
  18. width: 100%;
  19. font-size: 12px;
  20. text-decoration: none;
  21. }
  22. #wrapper{
  23. position: relative;
  24. top: 80px;
  25. width: 404px;
  26. }
  27. .center {
  28. left: 50%;
  29. -webkit-transform: translate( -50% );
  30. -ms-transform: translate( -50% );
  31. transform: translate( -50% );
  32. }
  33.  
  34. /*===== The CSS =====*/
  35. .progress{
  36. width: 200px;
  37. height: 280px;
  38. }
  39. .progress .track, .progress .fill{
  40. fill: rgba(0, 0, 0, 0);
  41. stroke-width: 3;
  42. transform: rotate(90deg)translate(0px, -80px);
  43. }
  44. .progress .track{
  45. stroke: rgb(56, 71, 83);
  46. }
  47. .progress .fill {
  48. stroke: rgb(255, 255, 255);
  49. stroke-dasharray: 219.99078369140625;
  50. stroke-dashoffset: -219.99078369140625;
  51. transition: stroke-dashoffset 1s;
  52. }
  53. .progress.blue .fill {
  54. stroke: rgb(51, 102, 255);
  55. }
  56. .progress.orange .fill {
  57. stroke: rgb(255, 204, 102);
  58. }
  59. .progress.pink .fill {
  60. stroke: rgb(255, 102, 204);
  61. }
  62. .progress.red .fill {
  63. stroke: rgb(255, 51, 0);
  64. }
  65. .progress.green .fill {
  66. stroke: rgb(0, 255, 204);
  67. }
  68. .progress.purple .fill {
  69. stroke: rgb(204, 102, 255);
  70. }
  71.  
  72. .progress .value, .progress .text {
  73. font-family: 'Open Sans';
  74. fill: rgb(0, 0, 0);
  75. text-anchor: middle;
  76. }
  77. .progress .text {
  78. font-size: 12px;
  79. }
  80. .noselect {
  81. -webkit-touch-callout: none;
  82. -webkit-user-select: none;
  83. -khtml-user-select: none;
  84. -moz-user-select: none;
  85. -ms-user-select: none;
  86. user-select: none;
  87. cursor: default;
  88. }
  89.  
  90.  
  91. </style>
  92. </head>
  93. <body>
  94.  
  95. <div id="wrapper" class="center">
  96. <svg class="progress blue noselect" data-progress="85" x="0px" y="0px" viewBox="0 0 80 80">
  97. <path class="track" d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0" />
  98. <path class="fill" d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0" />
  99. <text class="value" x="50%" y="55%">0%</text>
  100. <text class="text" x="50%" y="115%">Photoshop</text>
  101. </svg>
  102. <svg class="progress orange noselect" data-progress="90" x="0px" y="0px" viewBox="0 0 80 80">
  103. <path class="track" d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0" />
  104. <path class="fill" d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0" />
  105. <text class="value" x="50%" y="55%">0%</text>
  106. <text class="text" x="50%" y="115%">Illustrator</text>
  107. </svg>
  108. <svg class="progress pink noselect" data-progress="80" x="0px" y="0px" viewBox="0 0 80 80">
  109. <path class="track" d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0" />
  110. <path class="fill" d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0" />
  111. <text class="value" x="50%" y="55%">0%</text>
  112. <text class="text" x="50%" y="115%">InDesign</text>
  113. </svg>
  114. <svg class="progress red noselect" data-progress="90" x="0px" y="0px" viewBox="0 0 80 80">
  115. <path class="track" d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0" />
  116. <path class="fill" d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0" />
  117. <text class="value" x="50%" y="55%">0%</text>
  118. <text class="text" x="50%" y="115%">Micrsoft Office</text>
  119. </svg>
  120. <svg class="progress green noselect" data-progress="93" x="0px" y="0px" viewBox="0 0 80 80">
  121. <path class="track" d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0" />
  122. <path class="fill" d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0" />
  123. <text class="value" x="50%" y="55%">0%</text>
  124. <text class="text" x="50%" y="115%">Photography</text>
  125. </svg>
  126. <svg class="progress purple noselect" data-progress="40" x="0px" y="0px" viewBox="0 0 80 80">
  127. <path class="track" d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0" />
  128. <path class="fill" d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0" />
  129. <text class="value" x="50%" y="55%">0%</text>
  130. <text class="text" x="50%" y="115%">HTML/CSS</text>
  131. </svg>
  132. </div>
  133.  
  134.  
  135. <script>
  136. /* Set Progress | jQuery
  137. ======================================*/
  138. /*
  139. $(document).ready(function(){
  140. var max = 150.72259521484375;
  141. $.each($('.progress'), function( index, value ){
  142. percent = $(value).data('progress');
  143. $(value).children($('.fill')).attr('style', 'stroke-dashoffset: ' + ((100 - percent) / 100) * max);
  144. $(value).children($('.value')).text(percent + '%');
  145. });
  146. });
  147. */
  148.  
  149.  
  150. var forEach = function (array, callback, scope) {
  151. for (var i = 0; i < array.length; i++) {
  152. callback.call(scope, i, array[i]);
  153. }
  154. };
  155. window.onload = function(){
  156. var max = -219.99078369140625;
  157. forEach(document.querySelectorAll('.progress'), function (index, value) {
  158. percent = value.getAttribute('data-progress');
  159. value.querySelector('.fill').setAttribute('style', 'stroke-dashoffset: ' + ((100 - percent) / 100) * max);
  160. value.querySelector('.value').innerHTML = percent + '%';
  161. });
  162. }
  163.  
  164.  
  165.  
  166. /*
  167.  
  168. Used to calc the variable 'max'
  169. and set 'stroke-dasharray' and
  170. 'stroke-dashoffset' in the css
  171.  
  172.  
  173. console.log(document.querySelector('.fill').getTotalLength());
  174.  
  175. */
  176. </script>
  177.  
  178. </body>
  179. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement