Create Model Using CSS & JavaScript

JavaScript is the most trending Computer language in the world, In today article we will create CSS & JavaScript Model.

CSS and JavaScript Model: 

Javascript and CSS are the most demanding languages in the industry, we can create a complex user interface using CSS and JavaScript. In this article, we will create vanilla/Pure CSS and JavaScript Model from scratch, a model is just a popup window which appears and disappears and clicks event normally same like Bootstrap framework model if you are familiar with the Bootstrap framework. So now let's get started, first of all, create an index.html file and copy the below code and paste the copied code in your index.html file.
Create Model Using CSS & JavaScript
Create Model Using CSS & JavaScript

index.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">
    <title>Vanilla JS & CSS Model</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
   <button id="btn">Click me</button> 
   <div class="model-section">
    <div class="model">
     <div class="model--header">
     <h3>Model header </h3>
     <span id="close">&times;</span>
     </div>
     <!-- Close model--header -->
     <div class="model--body">
         Lorem, ipsum dolor sit amet consectetur adipisicing elit. Amet officia reprehenderit quibusdam sunt laudantium voluptatibus corrupti atque nulla magnam aut quae earum dolore laborum, eveniet necessitatibus assumenda neque voluptates inventore?Lorem ipsum dolor sit amet consectetur adipisicing elit. Dicta minus necessitatibus explicabo architecto sit facere minima consequuntur excepturi perferendis saepe, debitis tenetur, placeat, numquam praesentium optio quia. Nesciunt, et voluptatibus. Lorem, ipsum dolor sit amet consectetur adipisicing elit. In dolores aliquid possimus obcaecati accusantium hic illum blanditiis iure! Totam molestias assumenda culpa quidem ullam modi odit earum nam sit obcaecati?
     </div>
    </div>
    <!-- Close model -->
   </div>
   <!-- Close model-section -->

</body>
</html>

Model.js


   const btn = document.getElementById("btn");
   const model = document.querySelector(".model-section");
   const close = document.getElementById("close");
         btn.addEventListener("click", function(){
             model.style.display = "block";
         });

         close.addEventListener("click", function(){
             model.style.display = "none";
         });

         model.addEventListener("click", function(e){
           let className = e.target.getAttribute("class");
           if(className === "model-section"){
               model.style.display = "none";
           }
         })

style.css


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

body {
    font-family: sans-serif;
    padding: 30px;
}

#btn {
    display: inline-block;
    padding: 13px 14px;
    border-radius: 4px;
    color: #fff;
    background: #FF3D00;
    cursor: pointer;
    outline: none;
    border: none;
}

.model-section {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,.6);
    z-index: 1;
    display: none;
}

.model {
    width: 60%;
    height: auto;
    border-radius: 5px;
    background: #fff;
    margin: 10% auto;
    overflow: hidden;
    animation: modelAnimate .5s;
}

@keyframes modelAnimate {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.model--header {
    background: #FF3D00;
    color: #fff;
    padding: 20px;
}

#close {
    display: block;
    font-size: 25px;
    float: right;
    margin-top: -25px;
    cursor: pointer;
}

.model--body {
    padding: 20px;
}

COMMENTS

Name

ajax,2,HTML & CSS,19,JavaScript,1,PHP,11,
ltr
item
webtipstricks: Create Model Using CSS & JavaScript
Create Model Using CSS & JavaScript
JavaScript is the most trending Computer language in the world, In today article we will create CSS & JavaScript Model.
https://i.ytimg.com/vi/4qcY6edlsEQ/hqdefault.jpg
https://i.ytimg.com/vi/4qcY6edlsEQ/default.jpg
webtipstricks
https://www.webtipstricks.com/2019/01/create-model-using-css-javascript.html
https://www.webtipstricks.com/
https://www.webtipstricks.com/
https://www.webtipstricks.com/2019/01/create-model-using-css-javascript.html
true
4027471107773963481
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy