File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
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+ < link rel ="stylesheet " href ="style.css ">
8+ < title > Refresh For New Color</ title >
9+ </ head >
10+ < body >
11+ < div class ="color-container ">
12+ < h1 class ="color-code "> </ h1 >
13+ </ div >
14+ < script src ="./script.js "> </ script >
15+ </ body >
16+ </ html >
Original file line number Diff line number Diff line change 1+ let color_container = document . querySelector ( ".color-container" )
2+ let color_code = document . querySelector ( ".color-code" )
3+
4+ window . addEventListener ( "load" , ( ) => {
5+ let RGB_color = RandomColorGenerator ( )
6+ console . log ( RGB_color )
7+ color_container . style . backgroundColor = RGB_color
8+ color_code . innerHTML = RGB_color
9+ } )
10+
11+
12+ function RandomColorGenerator ( ) {
13+ let red = Math . floor ( Math . random ( ) * 255 )
14+ let blue = Math . floor ( Math . random ( ) * 255 )
15+ let green = Math . floor ( Math . random ( ) * 255 )
16+
17+ let rgb = `rgb(${ red } , ${ green } , ${ blue } )`
18+
19+ return rgb
20+ }
21+
Original file line number Diff line number Diff line change 1+ * {
2+ padding : 0 ;
3+ margin : 0 ;
4+ box-sizing : border-box;
5+ }
6+ body {
7+ font-family : monospace;
8+ }
9+ .color-container {
10+ width : 100% ;
11+ height : 100vh ;
12+ background-color : # ccc ;
13+ display : flex;
14+ justify-content : center;
15+ align-items : center;
16+ }
17+ .color-code {
18+ font-size : 16px ;
19+ user-select : none;
20+ }
You can’t perform that action at this time.
0 commit comments