File tree Expand file tree Collapse file tree 9 files changed +67
-0
lines changed
Expand file tree Collapse file tree 9 files changed +67
-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 name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < link rel ="stylesheet " href ="style.css ">
7+ < title > DICE ROLLER</ title >
8+ </ head >
9+ < body >
10+ < div id ="container ">
11+ < h1 > DICE ROLLER</ h1 >
12+ < label > No of dice:</ label >
13+ < input type ="number " value ="1 " id ="noofdice " min ="1 ">
14+ < button type ="button " onclick ="roll() "> Roll</ button >
15+ < div id ="diceresult "> </ div >
16+ < div id ="diceimages "> </ div >
17+ </ div >
18+ < script src ="index.js "> </ script >
19+ </ body >
20+ </ html >
Original file line number Diff line number Diff line change 1+ function roll ( ) {
2+
3+ const noofdice = document . getElementById ( "noofdice" ) . value ;
4+ const diceresult = document . getElementById ( "diceresult" ) ;
5+ const diceimages = document . getElementById ( "diceimages" ) ;
6+ const values = [ ] ;
7+ const images = [ ] ;
8+
9+ for ( let i = 0 ; i < noofdice ; i ++ ) {
10+ const value = Math . floor ( Math . random ( ) * 6 ) + 1 ;
11+ values . push ( value ) ; images . push ( `<div style="display:inline-block; text-align:center; margin:5px;">
12+ <img src="img/${ value } .jpg" style="width:80px; height:80px;">
13+ <div style="font-size:20px; font-weight:normal;">dice no ${ i + 1 } </div>
14+ </div>` ) ;
15+
16+ }
17+ diceresult . textContent = `dice values :${ values . join ( ", " ) } ` ;
18+ diceimages . innerHTML = images . join ( ' ' ) ;
19+ }
Original file line number Diff line number Diff line change 1+ # container {
2+ font-family : Arial, sans-serif;
3+ text-align : center;
4+ font-size : 2rem ;
5+ font-weight : bold;
6+ }
7+ button {
8+ font-size : 1.5rem ;
9+ padding : 10px 15px ;
10+ border-radius : 15px ;
11+ border : none;
12+ background-color : rgb (245 , 138 , 255 );
13+ cursor : pointer;
14+ font-weight : bold;
15+ color : white;
16+ }
17+ button : hover {
18+ background-color : rgb (244 , 92 , 255 );
19+ }
20+ button : active {
21+ background-color : rgb (225 , 185 , 228 );
22+ }
23+ input {
24+ font-size : 2rem ;
25+ width : 150px ;
26+ font-weight : bold;
27+ text-align : center;
28+ }
You can’t perform that action at this time.
0 commit comments