Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added dice/README.md
Empty file.
51 changes: 51 additions & 0 deletions dice/design.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
body{
background-color: yellow;
}


div{

width: 100px;
height: 100px;
border: 3px solid black;
margin: 100px auto;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
align-content: center;

}

.rotate{
animation-name: rotate;
animation-duration: 1s;
animation-timing-function: ease-in;
animation-iteration-count: 1;

}

@keyframes rotate {
0%{
transform: rotate(120deg);
}

20%{
transform: rotateX(120deg);
}

}

button{
margin-left: 48%;

}

.dot{
width: 5px;
height: 5px;
border-radius: 50%;
background-color: black;
margin: 0;

}
16 changes: 16 additions & 0 deletions dice/dice.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dic</title>

<link rel="stylesheet" href="design.css" >

</head>
<body>
<div class="box"></div>
<button>Click me</button>
<script src="dice.js"></script>
</body>
</html>
45 changes: 45 additions & 0 deletions dice/dice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
let button =document.querySelector("button")

let div=document.querySelector("div");
let c=0;
button.addEventListener('click',()=>{
c++;
if(c==2)
{
let alldot=Array.from(document.getElementsByClassName("dot"))

for(let i=0;i<alldot.length;i++)
{
alldot[i].remove();
}

c=1;
}
let m=Math.floor(Math.random()*(6-1+1)+1);
console.log("r"+m)
div.classList.add("rotate")
setTimeout(() => {
div.classList.remove("rotate")

}, 1000);
let i=1;
while(i<=m){

let dot=document.createElement("div");
dot.setAttribute("class","d")

dot.classList.add("dot")
div.appendChild(dot);
console.log("d"+i);

i++;
}




console.log(c);



})