Using CSS3 to make dynamic clock special effects code

Source: Internet
Author: User

CSS3 Many novel functions, can produce a lot of cool effects, such as today to introduce this, foreign cattle people using pure CSS3 animation produced a dynamic clock effect, it uses pure CSS3 animation and graphics, no use of any pictures or JavaScript script.

A dynamic clock made of pure CSS3 animation

HTML code


<div id= "Watch" >


<div class= "Frame-face" ></div>


<ul class= "Minute-marks" >


<li></li><li></li><li></li><li></li><li></li>< Li></li>


<li></li><li></li><li></li><li></li><li></li>< Li></li>


<li></li><li></li><li></li><li></li><li></li>< Li></li>


<li></li><li></li><li></li><li></li><li></li>< Li></li>


<li></li><li></li><li></li><li></li><li></li>< Li></li>


<li></li><li></li><li></li><li></li><li></li>< Li></li>


<li></li><li></li><li></li><li></li><li></li>< Li></li>


<li></li><li></li><li></li><li></li><li></li>< Li></li>


</ul>


<div class= "Digital-wrap" >


<ul class= "Digit-hours" >


<li>23</li>


<li>00</li><li>01</li><li>02</li><li>03</li><li>04</ Li><li>05</li>


<li>06</li><li>07</li><li>08</li><li>09</li><li>10</ Li><li>11</li>


<li>12</li><li>13</li><li>14</li><li>15</li><li>16</ Li><li>17</li>


<li>18</li><li>19</li><li>20</li><li>21</li><li>22</ Li>


</ul>


<ul class= "Digit-minutes" >


<li>10</li><li>11</li>


<li>12</li><li>13</li><li>14</li><li>15</li><li>16</ Li><li>17</li>


<li>18</li><li>19</li><li>20</li><li>21</li><li>22</ Li><li>23</li>


<li>24</li><li>25</li><li>26</li><li>27</li><li>28</ Li><li>29</li>


<li>30</li><li>31</li><li>32</li><li>33</li><li>34</ Li><li>35</li>


<li>36</li><li>37</li><li>38</li><li>39</li><li>40</ Li><li>41</li>


<li>42</li><li>43</li><li>44</li><li>45</li><li>46</ Li><li>47</li>


<li>48</li><li>49</li><li>50</li><li>51</li><li>52</ Li><li>53</li>


<li>54</li><li>55</li><li>56</li><li>57</li><li>58</ Li><li>59</li>


<li>00</li><li>01</li><li>02</li><li>03</li><li>04</ Li><li>05</li>


<li>06</li><li>07</li><li>08</li><li>09</li>


</ul>


<ul class= "Digit-seconds" >


<li>20</li><li>21</li><li>22</li><li>23</li>


<li>24</li><li>25</li><li>26</li><li>27</li><li>28</ Li><li>29</li>


<li>30</li><li>31</li><li>32</li><li>33</li><li>34</ Li><li>35</li>


<li>36</li><li>37</li><li>38</li><li>39</li><li>40</ Li><li>41</li>


<li>42</li><li>43</li><li>44</li><li>45</li><li>46</ Li><li>47</li>


<li>48</li><li>49</li><li>50</li><li>51</li><li>52</ Li><li>53</li>


<li>54</li><li>55</li><li>56</li><li>57</li><li>58</ Li><li>59</li>


<li>00</li><li>01</li><li>02</li><li>03</li><li>04</ Li><li>05</li>


<li>06</li><li>07</li><li>08</li><li>09</li><li>10</ Li><li>11</li>


<li>12</li><li>13</li><li>14</li><li>15</li><li>16</ Li><li>17</li>


<li>18</li><li>19</li>


</ul>


</div>


<ul class= "Digits" >


<li>1</li><li>2</li><li>3</li><li>4</li><li>5</li> <li>6</li>


<li>7</li><li>8</li><li>9</li><li>10</li><li>11</li ><li>12</li>


</ul>


<div class= "Hours-hand" ></div>


<div class= "Minutes-hand" ></div>


<div class= "Seconds-hand" ></div>


</div>


CSS Code


body {font-size:62.5%; margin:1em; background: #232425}


UL {list-style:none; margin:0; padding:0}


#watch {font-size:1em; position:relative}


#watch. frame-face {


position:relative;


Width:30em;


Height:30em;


MARGIN:2EM Auto;


Border-radius:15em;


Background:-webkit-linear-gradient (Top, #f9f9f9, #666);


Background:-moz-linear-gradient (Top, #f9f9f9, #666);


Background:linear-gradient (to bottom, #f9f9f9, #666);


Box-shadow:rgba (0,0,0,.8) 5em. 5em 4em;


}


#watch. Frame-face:before {


Content: ';


Width:29.4em;


Height:29.4em;


Border-radius:14.7em;


Position:absolute;


Top:.3em; Left:.3em;


Background


-webkit-linear-gradient (135deg, Rgba (246,248,249,0) 0%,rgba (229,235,238,1) 50%,rgba (205,212,217,1) 51%,rgba ( 245,247,249,0) 100%),


-webkit-radial-gradient (center, ellipse cover, Rgba (246,248,249,1) 0%,rgba (229,235,238,1) 65%,rgba (205,212,217,1) 66 %,rgba (245,247,249,1) 100%);


Background


-moz-linear-gradient (135deg, Rgba (246,248,249,0) 0%,rgba (229,235,238,1) 50%,rgba (205,212,217,1) 51%,rgba ( 245,247,249,0) 100%),


-moz-radial-gradient (center, ellipse cover, Rgba (246,248,249,1) 0%,rgba (229,235,238,1) 65%,rgba (205,212,217,1) 66%, Rgba (245,247,249,1) 100%);


Background


Linear-gradient (135deg, Rgba (246,248,249,0) 0%,rgba (229,235,238,1) 50%,rgba (205,212,217,1) 51%,rgba (245,247,249,0) 100%),


Radial-gradient (ellipse at center, RGBA (246,248,249,1) 0%,rgba (229,235,238,1) 65%,rgba (205,212,217,1) 66%,rgba ( 245,247,249,1) 100%);


}


#watch. Frame-face:after {


Content: ';


Width:28em;


Height:28em;


Border-radius:14.2em;


Position:absolute;


Top:.9em; Left:.9em;


Box-shadow:inset Rgba (0,0,0,.2) 2em. 2EM 1em;


Border:.1em solid Rgba (0,0,0,.2);


Background:-webkit-linear-gradient (Top, #fff, #ccc);


Background:-moz-linear-gradient (Top, #fff, #ccc);


Background:linear-gradient (to bottom, #fff, #ccc);


}


#watch. Minute-marks Li {


Display:block;


Width:.2em;


Height:.6em;


Background: #929394;


Position:absolute;


top:50%; left:50%;


Margin:-.4em 0 0-.1em;


}


#watch. Minute-marks li:first-child {transform:rotate (6deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (2) {transform:rotate (12deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (3) {transform:rotate (18deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (4) {transform:rotate (24deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (5) {transform:rotate (36deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (6) {transform:rotate (42deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (7) {transform:rotate (48deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (8) {transform:rotate (54deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (9) {transform:rotate (66deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (a) {transform:rotate (72deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (one) {transform:rotate (78deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (a) {transform:rotate (84deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (a) {transform:rotate (96deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (102deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (108deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (114deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (126deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (a) {transform:rotate (132deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (138deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (144deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (156deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (162deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (168deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (174deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (186deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (a) {transform:rotate (192deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (a) {transform:rotate (198deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (204deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (216deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (222deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (To) {transform:rotate (228deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (234deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (a) {transform:rotate (246deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (252deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child (km) {transform:rotate (258deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (+) {transform:rotate (264deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (Panax) {transform:rotate (276deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (pdf) {transform:rotate (282deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child (km) {transform:rotate (288deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (+) {transform:rotate (294deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (a) {transform:rotate (306deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (312deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (318deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (324deg) Translatey ( -12.7em)}


#watch. Minute-marks li:nth-child {transform:rotate (336deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (+) {transform:rotate (342deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child ($) {transform:rotate (348deg) Translatey ( -12.7em)}


#watch. Minute-marks Li:nth-child (a) {transform:rotate (354deg) Translatey ( -12.7em)}


#watch. Digits {


Width:30em;


Height:30em;


Border-radius:15em;


Position:absolute;


top:0; left:50%;


Margin-left:-15em;


}


#watch. digits Li {


Font-size:1.6em;


Display:block;


Width:1.6em;


Height:1.6em;


Position:absolute;


top:50%; left:50%;


Line-height:1.6em;


Text-align:center;


Margin:-.8em 0 0-.8em;


Font-weight:bold;


}


#watch. Digits Li:nth-child (1) {transform:translate (3.9em, -6.9em)}


#watch. Digits Li:nth-child (2) {transform:translate (6.9em, -4em)}


#watch. Digits Li:nth-child (3) {transform:translate (8em, 0)}


#watch. Digits Li:nth-child (4) {transform:translate (6.8em, 4em)}


#watch. Digits Li:nth-child (5) {transform:translate (3.9em, 6.9em)}


#watch. Digits Li:nth-child (6) {transform:translate (0, 8em)}


#watch. Digits Li:nth-child (7) {transform:translate ( -3.9em, 6.9em)}


#watch. Digits Li:nth-child (8) {transform:translate ( -6.8em, 4em)}


#watch. Digits Li:nth-child (9) {transform:translate ( -8em, 0)}


#watch. Digits Li:nth-child (a) {transform:translate ( -6.9em, -4em)}


#watch. Digits Li:nth-child (one) {transform:translate ( -3.9em, -6.9em)}


#watch. Digits li:nth-child {transform:translate (0, -8em)}


#watch. Digits:before {


Content: ';


Width:1.6em;


Height:1.6em;


Border-radius:.8em;


Position:absolute;


top:50%; left:50%;


Margin:-.8em 0 0-.8em;


Background: #121314;


}


#watch. Digits:after {


Content: ';


Width:4em;


Height:4em;


Border-radius:2.2em;


Position:absolute;


top:50%; left:50%;


Margin:-2.1em 0 0-2.1em;


Border:.1em solid #c6c6c6;


Background:-webkit-radial-gradient (center, ellipse cover, Rgba (200,200,200,0), Rgba (190,190,190,1) 90%, Rgba ( 130,130,130,1) 100%);


Background:-moz-radial-gradient (center, ellipse cover, Rgba (200,200,200,0), Rgba (190,190,190,1) 90%, Rgba ( 130,130,130,1) 100%);


Background:radial-gradient (ellipse at center, Rgba (200,200,200,0), Rgba (190,190,190,1) 90%, Rgba (130,130,130,1) 100%) ;


}


@keyframes hours {to {transform:rotate (335DEG)}}}


#watch. Hours-hand {


Width:.8em;


Height:7em;


border-radius:0 0 9em. 9em;


Background: #232425;


Position:absolute;


bottom:50%; left:50%;


margin:0 0-.8em-.4em;


Box-shadow: #232425 0 0 2px;


Transform-origin:0.4em 6.2em;


Transform:rotate ( -25DEG);


animation:hours 43200s linear 0s infinite;


}


#watch. Hours-hand:before {


Content: ';


Background:inherit;


Width:1.8em;


Height:.8em;


border-radius:0 0 8em. 8em;


Box-shadow: #232425 0 0 1px;


Position:absolute;


Top:-.7em; Left:-.5em;


}


#watch. Hours-hand:after {


Content: ';


width:0; height:0;


Border:.9em solid #232425;


border-width:0. 9em 2.4em. 9em;


Border-left-color:transparent;


Border-right-color:transparent;


Position:absolute;


Top:-3.1em; Left:-.5em;


}


@keyframes minutes {to {transform:rotate (422DEG)}}}


#watch. Minutes-hand {


Width:.8em;


Height:12.5em;


Border-radius:.5em;


Background: #343536;


Position:absolute;


bottom:50%; left:50%;


margin:0 0-1.5em-.4em;


Box-shadow: #343536 0 0 2px;


Transform-origin:0.4em 11em;


Transform:rotate (62DEG);


animation:minutes 3600s linear 0s infinite;


}


@keyframes seconds {to {transform:rotate (480DEG)}}}


#watch. Seconds-hand {


Width:.2em;


Height:14em;


Border-radius:.1em 1em 0 0/10em 10em 0 0;


Background: #c00;


Position:absolute;


bottom:50%; left:50%;


margin:0 0-2em-.1em;


Box-shadow:rgba (0,0,0,.8) 0 0 2em;


Transform-origin:0.1em 12em;


Transform:rotate (120DEG);


Animation:seconds 60s steps (end) 0s infinite;


}


#watch. Seconds-hand:after {


Content: ';


Width:1.4em;


Height:1.4em;


Border-radius:.7em;


Background:inherit;


Position:absolute;


Left:-.65em; Bottom:1.35em;


}


#watch. Seconds-hand:before {


Content: ';


Width:.8em;


Height:3em;


Border-radius:.2em 2em. 4em 4em/.2em. 2em 2em 2em;


Box-shadow:rgba (0,0,0,.8) 0 0 2em;


Background:inherit;


Position:absolute;


Left:-.35em; Bottom:-3em;


}


#watch. digital-wrap {


Width:9em;


Height:3em;


Border:.1em solid #222;


Border-radius:.2em;


Position:absolute;


top:50%; left:50%;


Margin:3em 0 0-4.5em;


Overflow:hidden;


Background: #4c4c4c;


Background:-webkit-linear-gradient (Top, #4c4c4c 0, #0f0f0f 100%);


Background:-moz-linear-gradient (Top, #4c4c4c 0, #0f0f0f 100%);


Background:-ms-linear-gradient (Top, #4c4c4c 0, #0f0f0f 100%);


Background:-o-linear-gradient (Top, #4c4c4c 0, #0f0f0f 100%);


Background:linear-gradient (to bottom, #4c4c4c 0, #0f0f0f 100%);


}


#watch. Digital-wrap UL {


Float:left;


Width:2.85em;


Height:3em;


Border-right:.1em solid #000;


Color: #ddd;


Font-family:consolas, Monaco, monospace;


}


#watch. Digital-wrap ul:last-child {Border:none}


#watch. digital-wrap Li {


Font-size:1.5em;


Line-height:2;


letter-spacing:2px;


Text-align:center;


position:relative;


left:1px;


}


#watch. digit-minutes Li {


ANIMATION:DSM 3600s steps (end) 0s infinite;


}


#watch. digit-seconds Li {


ANIMATION:DSM 60s steps (end) 0s infinite;


}


@keyframes DSM {


to {Transform:translatey ( -120em)}


}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.