File tree Expand file tree Collapse file tree 3 files changed +92
-24
lines changed Expand file tree Collapse file tree 3 files changed +92
-24
lines changed Original file line number Diff line number Diff line change 1717 < div class ="sc " id ="sc "> </ div >
1818 </ div >
1919 </ div >
20- < script type ="text/javascript ">
21- const deg = 6 ;
22- const hr = document . querySelector ( '#hr' ) ;
23- const mn = document . querySelector ( '#mn' ) ;
24- const sc = document . querySelector ( '#sc' ) ;
20+
21+ < div class ="mode ">
2522
26- setInterval ( ( ) => {
27- let day = new Date ( ) ;
28- let hh = day . getHours ( ) * 30 ;
29- let mm = day . getMinutes ( ) * deg ;
30- let ss = day . getSeconds ( ) * deg ;
23+ < input type =" checkbox " class =" checkbox " id =" checkbox " >
24+ < label for =" checkbox " class =" label " >
25+ < div class =' ball ' > </ div >
26+ </ label >
27+
3128
32- hr . style . transform = `rotateZ(${ ( hh ) + ( mm / 12 ) } deg)` ;
33- mn . style . transform = `rotateZ(${ mm } deg)` ;
34- sc . style . transform = `rotateZ(${ ss } deg)` ;
35- } ) ;
36- </ script >
37- < script data-name ="BMC-Widget " data-cfasync ="false " src ="https://cdnjs.buymeacoffee.com/1.0.0/widget.prod.min.js "
38- data-id ="Astrodevil " data-description ="Support me on Buy me a coffee!! "
39- data-message ="" data-color ="#40DCA5 "
40- data-position ="Right "
41- data-x_margin ="50 " data-y_margin ="50 ">
42- </ script >
29+ </ div >
30+ < script
31+ data-name ="BMC-Widget "
32+ data-cfasync ="false "
33+ src ="https://cdnjs.buymeacoffee.com/1.0.0/widget.prod.min.js "
34+ data-id ="Astrodevil "
35+ data-description ="Support me on Buy me a coffee!! "
36+ data-message =""
37+ data-color ="#40DCA5 "
38+ data-position ="Right "
39+ data-x_margin ="50 "
40+ data-y_margin ="50 "
41+ > </ script >
42+ < script src ="../assets/Js/analog_clock1.js "> </ script >
4343</ body >
4444</ html >
Original file line number Diff line number Diff line change 1212 hr . style . transform = `rotateZ(${ ( hh ) + ( mm / 12 ) } deg)` ;
1313 mn . style . transform = `rotateZ(${ mm } deg)` ;
1414 sc . style . transform = `rotateZ(${ ss } deg)` ;
15- } ) ;
15+ } ) ;
16+
17+ const checkbox = document . getElementById ( "checkbox" ) ;
18+ const body = document . querySelector ( "body" ) ;
19+ const label = document . querySelector ( ".label" ) ;
20+ const root = document . querySelector ( ":root" ) ;
21+ const ball = document . querySelector ( ".ball" ) ;
22+ checkbox . addEventListener ( "change" , function ( ) {
23+ if ( this . checked ) {
24+ body . style . background = "black" ;
25+ label . style . backgroundColor = "#40DCA5" ;
26+ root . style . setProperty ( "--sec-color" , "#fff" ) ;
27+ ball . style . backgroundColor = "#fff" ;
28+ } else {
29+ body . style . background = "skyblue" ;
30+ label . style . backgroundColor = "white" ;
31+ root . style . setProperty ( "--sec-color" , "red" ) ;
32+ ball . style . backgroundColor = "black" ;
33+ }
34+ } ) ;
35+
Original file line number Diff line number Diff line change 44 padding : 0 ;
55 box-sizing : border-box;
66 }
7+
8+ : root {
9+ --sec-color : red;
10+ }
11+
712body
813{
914 display : flex;
1621 {
1722 width : 350px ;
1823 height : 350px ;
24+ margin-top : -10vh ;
1925 display : flex;
2026 justify-content : center;
2127 align-items : center;
@@ -74,10 +80,11 @@ z-index: 10000;
7480 width : 8px ;
7581 height : 80px ;
7682 background : lightgrey;
77-
7883 z-index : 10 ;
7984 border-radius : 6px 6px 0 0 ;
8085}
86+
87+
8188.mn : before
8289{
8390 content : ' ' ;
@@ -94,7 +101,48 @@ z-index: 10000;
94101 position : absolute;
95102 width : 2px ;
96103 height : 150px ;
97- background : red ;
104+ background : var ( --sec-color ) ;
98105 z-index : 12 ;
99106 border-radius : 6px 6px 0 0 ;
100107}
108+
109+ .mode {
110+ position : absolute;
111+ margin-top : 60vh ;
112+ align-content : center;
113+ }
114+
115+ .checkbox {
116+ opacity : 0 ;
117+ position : absolute;
118+ }
119+
120+ .label {
121+ width : 50px ;
122+ height : 26px ;
123+ background-color : # fff ;
124+ display : flex;
125+ border-radius : 50px ;
126+ align-items : center;
127+ justify-content : space-between;
128+ padding : 5px ;
129+ position : relative;
130+ transform : scale (1.5 );
131+ }
132+
133+ .ball {
134+ width : 20px ;
135+ height : 20px ;
136+ background-color : black;
137+ box-shadow : 0 0 2px black;
138+ position : absolute;
139+ top : 3px ;
140+ left : 2px ;
141+ border-radius : 50% ;
142+ transition : transform 0.2s linear;
143+ }
144+
145+ /* target the elemenent after the label*/
146+ .checkbox : checked + .label .ball {
147+ transform : translateX (24px );
148+ }
You can’t perform that action at this time.
0 commit comments