odin-default-css-exercises/animation/03-pop-up/solution/solution.css

117 lines
2.1 KiB
CSS
Raw Normal View History

2021-10-18 21:33:12 +00:00
* {
padding: 0;
margin: 0;
}
2021-10-20 22:05:31 +00:00
body {
overflow: hidden;
}
.button-container {
2021-10-18 21:33:12 +00:00
width: 100vw;
height: 100vh;
2021-10-20 20:40:44 +00:00
background-color: #ffffff;
2021-10-20 22:05:31 +00:00
opacity: 100%;
2021-10-20 20:40:44 +00:00
}
#trigger-modal,
.popup-modal {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
2021-10-18 21:33:12 +00:00
}
2021-10-20 22:05:31 +00:00
#trigger-modal {
padding: 20px;
color: #ffffff;
background-color: #0e79dd;
border: none;
border-radius: 5px;
font-weight: 600;
}
2021-10-21 19:21:32 +00:00
.popup-modal {
2021-10-18 21:33:12 +00:00
width: 30%;
2021-10-20 22:05:31 +00:00
height: 15%;
2021-10-18 21:33:12 +00:00
background-color: white;
2021-10-20 22:05:31 +00:00
border: 1px solid black;
border-radius: 10px;
2021-10-18 21:33:12 +00:00
display: flex;
2021-10-20 22:05:31 +00:00
justify-content: center;
align-items: center;
margin-top: 10%;
opacity: 0;
}
#close-modal {
padding: 20px;
color: #ffffff;
background-color: #0e79dd;
border: none;
border-radius: 5px;
font-weight: 600;
}
2021-10-21 19:21:32 +00:00
/* SOLUTION */
/*
Disclaimer: duplicating selectors here isn't best practice.
We separated it out here to make it extra clear what has changed.
*/
.button-container {
transition: background-color 0.5s ease-in, opacity 0.5s ease-in;
}
.button-container.show {
background-color: #000000;
opacity: 40%;
}
#trigger-modal:hover,
2021-10-20 22:05:31 +00:00
#close-modal:hover {
cursor: pointer;
box-shadow: 1px 1px 2px #000000;
2021-10-18 21:33:12 +00:00
}
2021-10-21 19:21:32 +00:00
/*
Keep this '.popup-modal' selector separate from the main
.popup-modal selector, for the reasons outlined above
.pop-up-modal.show
*/
.popup-modal {
visibility: hidden;
transition: margin-top 0.5s ease-out, opacity 0.5s ease-out,
visibility 0.5s linear;
}
/*
The common properties between .popup-modal and .popup-modal.show
can easily be added by just adding this selector to the main
.popup-modal selector
*/
.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;
min-height: 90px;
}
/*
Keep this selector separate from the main '.popup-modal.show'
selector.
*/
.popup-modal.show {
opacity: 1;
visibility: visible;
margin-top: 0;
transition: margin-top 0.5s ease-out, opacity 0.5s ease-out,
visibility 0.5s linear;
}