Make desired outcome gif
This commit is contained in:
parent
660d23d9eb
commit
37187c9111
Binary file not shown.
After Width: | Height: | Size: 68 KiB |
|
@ -5,9 +5,15 @@
|
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Popup</title>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<link rel="stylesheet" href="index.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="popup-container"></div>
|
||||
<div class="button-container">
|
||||
<button id="trigger-modal">Open Modal</button>
|
||||
</div>
|
||||
<div class="popup-modal">
|
||||
<button id="close-modal">Close Modal</button>
|
||||
</div>
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
const openButton = document.getElementById('trigger-modal');
|
||||
const closeButton = document.getElementById('close-modal');
|
||||
|
||||
function toggleModal() {
|
||||
const container = document.querySelector('.button-container');
|
||||
const modalDiv = document.querySelector('.popup-modal');
|
||||
modalDiv.classList.toggle('show');
|
||||
container.classList.toggle('show');
|
||||
}
|
||||
|
||||
openButton.addEventListener('click', toggleModal);
|
||||
closeButton.addEventListener('click', toggleModal);
|
|
@ -3,15 +3,19 @@
|
|||
margin: 0;
|
||||
}
|
||||
|
||||
.popup-container {
|
||||
body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.button-container {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: #ffffff;
|
||||
opacity: 1;
|
||||
opacity: 100%;
|
||||
transition: background-color 0.5s ease-in, opacity 0.5s ease-in;
|
||||
}
|
||||
|
||||
.popup-container.show {
|
||||
.button-container.show {
|
||||
background-color: #000000;
|
||||
opacity: 40%;
|
||||
}
|
||||
|
@ -24,16 +28,59 @@
|
|||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.popup-modal {
|
||||
position: absolute;
|
||||
#trigger-modal {
|
||||
padding: 20px;
|
||||
color: #ffffff;
|
||||
background-color: #0e79dd;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#trigger-modal:hover {
|
||||
cursor: pointer;
|
||||
box-shadow: 1px 1px 2px #000000;
|
||||
}
|
||||
|
||||
.popup-modal,
|
||||
.popup-modal.show {
|
||||
width: 30%;
|
||||
border: 1px solid black;
|
||||
height: 15%;
|
||||
background-color: white;
|
||||
border: 1px solid black;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.popup-modal {
|
||||
margin-top: 10%;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: margin-top 0.5s ease-out, opacity 0.5s ease-out,
|
||||
visibility 0.5s linear;
|
||||
}
|
||||
|
||||
.popup-modal.show {
|
||||
min-height: 90px;
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
margin-top: 0;
|
||||
transition: margin-top 0.5s ease-out, opacity 0.5s ease-out,
|
||||
visibility 0.5s linear;
|
||||
}
|
||||
|
||||
#close-modal {
|
||||
padding: 20px;
|
||||
color: #ffffff;
|
||||
background-color: #0e79dd;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#close-modal:hover {
|
||||
cursor: pointer;
|
||||
box-shadow: 1px 1px 2px #000000;
|
||||
}
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<link rel="stylesheet" href="solution.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="popup-container">
|
||||
<button id="trigger-modal">Click Me!</button>
|
||||
<div class="button-container">
|
||||
<button id="trigger-modal">Open Modal</button>
|
||||
</div>
|
||||
<div class="popup-modal">
|
||||
<p>Hey there!</p>
|
||||
<button id="close-modal">X</button>
|
||||
<button id="close-modal">Close Modal</button>
|
||||
</div>
|
||||
<script src="solution.js"></script>
|
||||
</body>
|
||||
|
|
|
@ -1,19 +1,12 @@
|
|||
const openButton = document.getElementById('trigger-modal');
|
||||
const closeButton = document.getElementById('close-modal');
|
||||
|
||||
function openModal() {
|
||||
const container = document.querySelector('.popup-container');
|
||||
function toggleModal() {
|
||||
const container = document.querySelector('.button-container');
|
||||
const modalDiv = document.querySelector('.popup-modal');
|
||||
modalDiv.classList.add('show');
|
||||
container.classList.add('show');
|
||||
modalDiv.classList.toggle('show');
|
||||
container.classList.toggle('show');
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
const container = document.querySelector('.popup-container.show');
|
||||
const modalDiv = document.querySelector('.popup-modal.show');
|
||||
modalDiv.classList.remove('show');
|
||||
container.classList.remove('show');
|
||||
}
|
||||
|
||||
openButton.addEventListener('click', openModal);
|
||||
closeButton.addEventListener('click', closeModal);
|
||||
openButton.addEventListener('click', toggleModal);
|
||||
closeButton.addEventListener('click', toggleModal);
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
* {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.button-container {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: #ffffff;
|
||||
opacity: 100%;
|
||||
transition: background-color 0.5s ease-in, opacity 0.5s ease-in;
|
||||
}
|
||||
|
||||
.button-container.show {
|
||||
background-color: #000000;
|
||||
opacity: 40%;
|
||||
}
|
||||
|
||||
#trigger-modal,
|
||||
.popup-modal {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
#trigger-modal {
|
||||
padding: 20px;
|
||||
color: #ffffff;
|
||||
background-color: #0e79dd;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#trigger-modal:hover {
|
||||
cursor: pointer;
|
||||
box-shadow: 1px 1px 2px #000000;
|
||||
}
|
||||
|
||||
.popup-modal,
|
||||
.popup-modal.show {
|
||||
width: 30%;
|
||||
height: 15%;
|
||||
background-color: white;
|
||||
border: 1px solid black;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.popup-modal {
|
||||
margin-top: 10%;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: margin-top 0.5s ease-out, opacity 0.5s ease-out,
|
||||
visibility 0.5s linear;
|
||||
}
|
||||
|
||||
.popup-modal.show {
|
||||
min-height: 90px;
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
margin-top: 0;
|
||||
transition: margin-top 0.5s ease-out, opacity 0.5s ease-out,
|
||||
visibility 0.5s linear;
|
||||
}
|
||||
|
||||
#close-modal {
|
||||
padding: 20px;
|
||||
color: #ffffff;
|
||||
background-color: #0e79dd;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#close-modal:hover {
|
||||
cursor: pointer;
|
||||
box-shadow: 1px 1px 2px #000000;
|
||||
}
|
Loading…
Reference in New Issue