Skip to main content

Popup Modal Using Html, CSS and JavaScript

Video:







Source Code:


//HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="style.css">
    <title>Javascript Popup Modal</title>
</head>
<body>
    <button onclick="pop()" class="btn">Click Me!</button>
    <div id="box" class="box">
        <span onclick="hide()">&times;</span>
        <h2>Javascript Popup Modal</h2>
        <p>
            Lorem ipsum dolor sit amet consectetur adipisicing elit. Aut, expedita! Laudantium tempora voluptate fuga, vero omnis numquam iure quam quidem sequi? Autem enim officia illo ad sunt maiores minima possimus.
        </p>
    </div>
    <script src="main.js"></script>
</body>
</html>

// Css

*{
    margin: 0;
    padding: 0;
    font-family: Nunito;
    box-sizing: border-box;
}

.btn{
    background: #9b59b6;
    border: none;
    outline: none;
    color: #ffffff;
    padding: 10px;
    width: 10%;
    font-size: larger;
    cursor: pointer;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
}

.box{
    background: #9b59b6;
    color: #ffffff;
    width: 40%;
    text-align: center;
    padding: 50px;
    border-radius: 8px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    display: none;
}

.box span{
    float: right;
    cursor: pointer;
    font-size: 20px;
}

.box h2{
    padding-bottom: 20px;
}



// JS 

function pop() {
    document.getElementById("box").style.display = "block";
}

function hide() {
    document.getElementById("box").style.display = "none";
}









Comments

Popular posts from this blog

Amazing 404 Error Page Using HTML & CSS

  Video: Source Code: <! DOCTYPE   html > < html   lang = "en" > < head >     < meta   charset = "UTF-8" >     < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >     < meta   http-equiv = "X-UA-Compatible"   content = "ie=edge" >     < title >Error! 404</ title > </ head > <style> * {     margin:  0 ;     padding:  0 ;     font-family: Nunito;     box-sizing:  border-box ; } body {     background:  linear-gradient (to  right ,  #48dbfb ,  #1dd1a1 );     display:  flex ;     align-items:  center ;     justify-content:  center ;     min-heigh...

Amazing Full Screen Landing Page Using Only Html & Css

In this post, you will learn to make an amazing FullScreen Landing Page Using Only Html & CSS. Here is the video and source code. Enjoy! ☺ VIDEO : SOURCE CODE: HTML : <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <script src="https://kit.fontawesome.com/82fb063a14.js" crossorigin="anonymous"></script>     <link rel="stylesheet" href="style.css">     <title>Amazing Full Screen Landing Page</title> </head> <body>     <div class="header">         <div class="main">             <ul>                 <li><a href="#"><i class="fab fa-facebook-f"></i></a></li>                 <li...

Pure CSS Hamburger Menu | Side Bar Menu

Video:  Source Code: HTML <! DOCTYPE   html > < html   lang = "en" > < head >      < meta   charset = "UTF-8" >      < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >      < meta   http-equiv = "X-UA-Compatible"   content = "ie=edge" >      < link   rel = "stylesheet"   href = "style.css" >      < title > Hamburger Menu </ title > </ head > < body >      < input   type = "checkbox"   name = ""   id = "check" >      < label   class = "ham_menu"   for = "check" > &#9776; </ label >      < div   class = "main" >          < label   for = "check" > &times; </ label ...