Skip to content

Commit e0c4a6a

Browse files
committed
New Project Added
1 parent 84b49f6 commit e0c4a6a

File tree

9 files changed

+67
-0
lines changed

9 files changed

+67
-0
lines changed

Source-Code/DiceRoller/img/1.jpg

22.5 KB
Loading

Source-Code/DiceRoller/img/2.jpg

17.3 KB
Loading

Source-Code/DiceRoller/img/3.jpg

13 KB
Loading

Source-Code/DiceRoller/img/4.jpg

22 KB
Loading

Source-Code/DiceRoller/img/5.jpg

11.6 KB
Loading

Source-Code/DiceRoller/img/6.jpg

23.1 KB
Loading

Source-Code/DiceRoller/index.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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>

Source-Code/DiceRoller/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
}

Source-Code/DiceRoller/style.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
}

0 commit comments

Comments
 (0)