Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <!DOCTYPE html>
    <html lang="en">
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <!--=============== BOXICONS ===============-->
        <link rel="stylesheet" href="">

        <!--=============== CSS ===============-->
        <link rel="stylesheet" href="assets/css/styles.css">

        <title>Responsive Modal Popup Swingcodes</title>
        <section class="modal container">
            <button class="modal__button" id="open-modal">
                Open Modal

            <div class="modal__container" id="modal-container">
                <div class="modal__content">
                    <div class="modal__close close-modal" title="Close">
                        <i class='bx bx-x'></i>

                    <img src="assets/img/star-trophy.png" alt="" class="modal__img">

                    <h1 class="modal__title">Good Job!</h1>
                    <p class="modal__description">Click the button to close</p>

                    <button class="modal__button modal__button-width">
                        View status

                    <button class="modal__button-link close-modal">

        <!--=============== MAIN JS ===============-->
        <script src="assets/js/main.js"></script>


                /*=============== GOOGLE FONTS ===============*/
@import url(';500&display=swap');

/*=============== VARIABLES CSS ===============*/
:root {
  /*========== Colors ==========*/
  --hue: 240;
  --first-color: hsl(var(--hue), 16%, 18%);
  --first-color-alt: hsl(var(--hue), 16%, 12%);
  --title-color: hsl(var(--hue), 8%, 15%);
  --text-color: hsl(var(--hue), 8%, 35%);
  --body-color: hsl(var(--hue), 100%, 99%);
  --container-color: #FFF;

  /*========== Font and typography ==========*/
  --body-font: 'Poppins', sans-serif;
  --big-font-size: 1.5rem;
  --normal-font-size: .938rem;

  /*========== z index ==========*/
  --z-modal: 1000;

@media screen and (min-width: 968px) {
  :root {
    --big-font-size: 1.75rem;
    --normal-font-size: 1rem;

/*=============== BASE ===============*/
  box-sizing: border-box;
  padding: 0;
  margin: 0;

  font-family: var(--body-font);
  font-size: var(--normal-font-size);

  background-color: var(--body-color);
  color: var(--text-color);
  position: relative;

  cursor: pointer;
  border: none;
  outline: none;

  max-width: 100%;
  height: auto;

/*=============== MODAL ===============*/
  margin-left: 1rem;
  margin-right: 1rem;

  height: 100vh;
  display: grid;
  place-items: center;

  display: inline-block;
  background-color: var(--first-color);
  color: #FFF;
  padding: 1rem 1.25rem;
  border-radius: .5rem;
  transition: .3s;

  background-color: var(--first-color-alt);

  position: absolute;
  top: 0;
  left: 0;
  background-color: hsla(var(--hue), 18%, 75%, .8);
  width: 100%;
  height: 100%;
  display: grid;
  align-items: flex-end;
  overflow: hidden;
  transition: all .3s;
  z-index: var(--z-modal);
  visibility: hidden;
  opacity: 0;

  /*=== Effect 3 ===*/
  /* perspective: 1000px; */

  position: relative;
  background-color: var(--container-color);
  text-align: center;
  padding: 3rem 2rem 2rem;
  border-radius: 1rem 1rem 0 0;
  transition: all .3s;

  /*=== Effect 1 ===*/
  transform: translateY(10%);

  /*=== Effect 2 ===*/
  /* transform: scale(.5) translateY(10%); */

  /*=== Effect 3 ===*/
  /* transform: rotateX(65deg) scale(.75) translateY(10%);
  transform-origin: 50% 100%; */

  width: 150px;
  margin-bottom: .75rem;

  display: inline-flex;
  background-color: var(--first-color);
  border-radius: .25rem;
  color: #FFF;
  font-size: 1.5rem;
  position: absolute;
  top: 2rem;
  right: 2rem;
  cursor: pointer;

  font-size: var(--big-font-size);
  color: var(--title-color);
  font-weight: 500;

  margin-bottom: 1.5rem;

  width: 90%;

  display: block;
  margin: 1rem auto 0;
  background-color: transparent;
  color: var(--first-color);
  font-weight: 500;

/* Show modal */
  visibility: visible;
  opacity: 1;

.show-modal .modal__content{
  /*=== Effect 1 ===*/
  transform: translateY(0);

  /*=== Effect 2 ===*/
  /* transform: scale(1) translateY(0); */

  /*=== Effect 3 ===*/
  /* transform: rotateX(0) scale(1) translateY(0); */

/*=============== BREAKPOINTS ===============*/
/* For small devices */
@media screen and (min-width: 576px){
    margin: auto;
    width: 380px;
    border-radius: 1.25rem;

    width: 170px;


                /*=============== SHOW MODAL ===============*/
const showModal = (openButton, modalContent) =>{
    const openBtn = document.getElementById(openButton),
    modalContainer = document.getElementById(modalContent)
    if(openBtn && modalContainer){
        openBtn.addEventListener('click', ()=>{

/*=============== CLOSE MODAL ===============*/
const closeBtn = document.querySelectorAll('.close-modal')

function closeModal(){
    const modalContainer = document.getElementById('modal-container')
closeBtn.forEach(c => c.addEventListener('click', closeModal))