Skip to content

Instantly share code, notes, and snippets.

@m2paulc
Created February 15, 2019 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m2paulc/7a300fff89068ac4ad24fe8530bd1485 to your computer and use it in GitHub Desktop.
Save m2paulc/7a300fff89068ac4ad24fe8530bd1485 to your computer and use it in GitHub Desktop.
CSS Challenge Day 041

CSS Challenge Day 041

Here's my submission for day 41 of the CSS Challenge.

A Pen by Paul on CodePen.

License.

<div class="frame">
<div class="center">
<div class="modal">
<svg width="24" height="24" viewBox="0 0 24 24" class="caution">
<path d="M13,14H11V10H13M13,18H11V16H13M1,21H23L12,2L1,21Z"></path>
</svg>
<span class="err-title">Oh snap!</span>
<p>An error has occured while running your report.
<br>
<br>
No need to panic. Evaluate where and what went wrong. You can do this!</p>
<button id="button">Dismiss</button>
</div>
</div>
</div>
// jQuery v3.3.1 is supported
// window.onload = loadModal;
document.addEventListener('DOMContentLoaded', loadModal, false);
function loadModal() {
setTimeout(showModal,1000);
}
function showModal() {
document.querySelector('.modal').classList.add('show');
}
document.querySelector('#button').addEventListener('click', function() {
document.querySelector('.modal').classList.add('hide');
})
<script src="https://100dayscss.com/codepen/js/jquery.min.js"></script>
// delete the following line if no text is used
// edit the line if you wanna use other fonts
@import url(https://fonts.googleapis.com/css?family=Open+Sans:700,300);
// use only the available space inside the 400x400 frame
.frame {
position: absolute;
top: 50%;
left: 50%;
width: 400px;
height: 400px;
margin-top: -200px;
margin-left: -200px;
border-radius: 2px;
box-shadow: 4px 8px 16px 0 rgba(0,0,0,0.1);
overflow: hidden;
background: #9D50BB; /* fallback for old browsers */
background: -webkit-linear-gradient(to right, #6E48AA, #9D50BB); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #6E48AA, #9D50BB); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
color: #333;
font-family: 'Open Sans', Helvetica, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
.modal {
background: #4A148C;
color: #fff;
padding: 20px 15px;
border-radius: 10px;
width: 250px;
height: 210px;
box-shadow: 8px 12px 8px 2px rgba(0,0,0,0.3);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
opacity: 0;
&.show {
-webkit-animation: show-modal 1s 1s both;
animation: show-modal 1s 1s both;
opacity: 1;
}
&.hide {
-webkit-animation: hide-modal 1s ease-in-out both;
animation: hide-modal 1s ease-in-out both;
}
.caution {
position: absolute;
top: 5px;
left: 40px;
width: 48px;
height: 48px;
fill: orangered;
}
.err-title {
display: block;
font-size: 18px;
line-height: 24px;
font-weight: bold;
margin: 15px 0;
}
p {
line-height: 1.25rem;
margin: 0;
padding: 0px 25px 10px 25px;
}
#button {
font-family: inherit;
font-size: 100%;
font-weight: bold;
letter-spacing: 1px;
line-height: 2.5;
margin: 0;
display: inline-block;
position: relative;
width: 280px;
top: 12px;
border: none;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
text-decoration: none;
background: #7E57C2;
color: #fff;
cursor: pointer;
text-align: center;
text-transform: uppercase;
transition: background 250ms ease-in-out,
transform 150ms ease;
-webkit-appearance: none;
-moz-appearance: none;
}
#button:hover {
background: #512DA8;
}
#button:focus {
outline: none;
outline-offset: -2px;
}
#button:active {
transform: scale(0.99);
}
}
@-webkit-keyframes show-modal {
0% {
-webkit-transform: scale(0);
transform: scale(0);
opacity: 0;
}
70% {
-webkit-transform: scale(1.1);
transform: scale(1.1);
opacity: 1;
}
90% {
-webkit-transform: scale(0.95);
transform: scale(0.95);
opacity: 1;
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
opacity: 1;
}
}
@keyframes show-modal {
0% {
-webkit-transform: scale(0);
transform: scale(0);
opacity: 0;
}
70% {
-webkit-transform: scale(1.1);
transform: scale(1.1);
opacity: 1;
}
90% {
-webkit-transform: scale(0.95);
transform: scale(0.95);
opacity: 1;
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
opacity: 1;
}
}
@-webkit-keyframes hide-modal {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
20% {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
100% {
-webkit-transform: scale(0);
transform: scale(0);
}
}
@keyframes hide-modal {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
20% {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
100% {
-webkit-transform: scale(0);
transform: scale(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment