Header Ads

Header ADS

Simple PopUp With Javascript

 Simple PopUp With Javascript 

Javascript .....

let myClickBtn = document.querySelector(".BtnMy");
let myPopupDiv = document.querySelector(".popup");


myClickBtn.addEventListener("click"function(){
    myPopupDiv.style.top="50%";
});




let xtr = document.querySelector(".full");
xtr.addEventListener("click"function(){
    myPopupDiv.style.top="-50%";
});

Css Code....

*{
    padding0;
    margin0;
}

/* body{
    background: linear-gradient(to right, #ff523b, rgb(239, 255, 16));
} */

.full{
    width100%;
    backgroundrgb(255227227);
    height100vh;
}

.BtnMe{
    positionabsolute;
    top50%;
    left50%;
}

.popup{
    color#000;
    backgroundlinear-gradient(to right#ff523brgb(23925516));
    width50%;
    height150px;
    positionfixed;
    border-radius10px;
    text-aligncenter;
    top-70%;
    left50%;
    transformtranslate(-50%,-50%);
    transitionall 1.2s;

}

Html Code...

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>ddd</title>
</head>

<body>

    <div class="full">
        <h2>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Necessitatibus, nulla.</h2>
    </div>


    <div class="BtnMe">
        <button class="BtnMy">Click Her</button>
    </div>



    <div class="popup">
        <h1>Some text her for popup</h1>
        <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Labore nesciunt vitae mollitia.</p>
    </div>
</body>
<script src="index.js"></script>

</html>

No comments

Powered by Blogger.