• Web10.Az Master Forum AZ domain pulsuz etdi..
  • Web10.Az-da SEO Turniri Çox yaxinda..

JavaScript Zer Atma Oyunu Numunesi (Cut Zer)

Qeyd olma Tarixi
16 Okt 2023
Mesaj
37
Web10+
23
ölkə
Azrebaycan
Şəhər
Baki
Bunuda paylasim belke maraqinda olan olub goturub yoxluyar dahada yaxsi edər

2 eded tesadufi zerin seçilerek ekranın gösterilmesine imkan veren JavaScript numunesi

şəkilleri adresini özünüz qeyd edin ki göresiz

Kod:
<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        html{
            font-size:62.5%;
        }
        body{
            background-color: #25373D;
        }
        .panel{
            margin:5rem auto;
            width: 50rem;
            background-color: #1DABB8;
        }
        .zarlar{
            height: 30rem;
            display: flex;
            justify-content: space-around;
            align-items: center;
        }
        .zarlar img{
            width: 40%;
        }
        .btn-panel{
            text-align: center;
            padding:5rem;
        }
        #zarAt{
           
        }
 
        /* CSS */
        .button-19 {
        appearance: button;
        background-color: #1899D6;
        border: solid transparent;
        border-radius: 16px;
        color: #FFFFFF;
        cursor: pointer;
        display: inline-block;
        font-size: 15px;
        font-weight: 700;
        letter-spacing: .8px;
        line-height: 20px;
        padding: 13px 16px;
        text-align: center;
        text-transform: uppercase;
        transition: filter .2s;
        vertical-align: middle;
        white-space: nowrap;
        width: 100%;
        }
 
 
        .button-19:hover:not(:disabled) {
        filter: brightness(1.2);
        }
    </style>
</head>
<body>
    <div class="panel">
        <div class="zarlar">
            <img src="zar.jpeg" alt="zar 1" class="zar">
            <img src="zar1.png" alt="zar 2" class="zar">
        </div>
        <div class="btn-panel">
            <button id="zerAt" class="button-19">Zer At</button>
        </div>
    </div>
    <script>
        const liste =[
            "zer.jpg",
            "zer1.png",
            "zer.jpg",
            "zer1.png",
            "zer.jpg",
            "zer1.png",
            ]
 
        document.querySelector("#zerAt").onclick=function(){
            let uzunluk = liste.length;
            let zer1 = liste[Math.floor(Math.random()*uzunluk)];
            let zer2 = liste[Math.floor(Math.random()*uzunluk)];
           
            document.querySelectorAll(".zer")[0].src=zer1;
            document.querySelectorAll(".zer")[1].src=zer2;
        }
    </script>
</body>
</html>
 
son redaktə:
Üst Alt