Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <div class="btn-wrap">
   <a href="#" class="btn modal-open" data-modal-open="modal-1">modal open !</a>
</div>
<div class="btn-wrap">
   <a href="#" class="btn modal-open" data-modal-open="modal-2">モーダルが上がるよ !</a>
</div>
<div class="btn-wrap">
   <a href="#" class="btn modal-open" data-modal-open="modal-3">モーダルの内容が多い時 !</a>
</div>

        <!-- modal -->
        <div class="modal" data-modal="modal-1">
          <div class="modal-cover"></div>         
          <div class="modal-inner">
            <div class="modal-content">
              <div class="modal-content-ttl">modal</div>
              <p>This is a modal that does not use jQuery.</p>
              <div class="btn-wrap">
                <a  href="#" class="btn btn-close">close </a>
              </div>
            </div>
          </div>
        </div>
        <div class="modal" data-modal="modal-2">
          <div class="modal-cover"></div>         
          <div class="modal-inner">
            <div class="modal-content">
              <div class="modal-content-ttl">モーダル</div>
              <p>jQueryを使わないモーダルだよ</p>
              <div class="btn-wrap">
                <a  href="#" class="btn btn-close">閉じる </a>
              </div>
            </div>
          </div>
        </div>
        <div class="modal" data-modal="modal-3">
          <div class="modal-cover"></div>         
          <div class="modal-inner">
            <div class="modal-content">
              <div class="modal-content-ttl">モーダル</div>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              <p>テキスト</p>
              
              <div class="btn-wrap">
                <a  href="#" class="btn btn-close">閉じる </a>
              </div>
            </div>
          </div>
        </div>
        <!-- modal -->

            
          
!

CSS

            
              //common
html{
  font-size:62.5%;
}
body{
  font-size:1.4rem;
}
//btn
.btn-wrap{
  margin-top:30px;
  text-align:center;
}
.btn {
	display: inline-block;
	min-width: 165px;
	position: relative;
  text-decoration:none;
	padding: 17.5px 10px;
	text-align: center;
	font-size: 1.2rem;
	color: #636363;
	background: #efefef;
	vertical-align: middle;
  transition:background .3s;
  &:hover{
    background:#ddd;
  }
}

//modal
.modal {
	position: fixed;
	display: flex;
	align-items: center;
	width: 100vw;
	height: 100vh;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	margin: auto;
	border: none;
	opacity: 0;
	z-index: -1;

	.btn-inner {
		margin-top: 23.5px;
	}


}

.modal-cover {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.5);
}

.modal-inner {
	width: 80vw;
  max-width:800px;
	max-height: 80vh;
	margin: auto;
	padding: 15px;
	background: #fff;
	overflow-y: auto;
	z-index: 1;
}


.modal-list-logo {
	border-bottom: 1px solid #ebebeb;
	padding-bottom: 25px;
	text-align: center;

	p {
		margin-top: 15px;
		font-size: 1.2rem;
	}

}

.modal-content {
	margin-top: 25px;
	text-align: left;
}

.modal-content-ttl {
	font-size: 2rem;
}
//modal animation
.modal {
	&.is-open {
		animation: modal_open .5s ease forwards;

		.modal-inner {
			animation: modal_inner_open .5s ease forwards;
		}
	}

	&.is-close {
		animation: modal_close .5s ease forwards;

		.modal-inner {
			animation: modal_inner_close .5s ease forwards;

		}
	}
}

@keyframes modal_open {
	0% {
		opacity: 0;
	}

	100% {
		opacity: 1;
		z-index: 10000;
	}
}

@keyframes modal_inner_open {
	0% {
		opacity: 0;
		transform: translateY(-20px);
	}

	100% {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes modal_close {
	0% {
		z-index: 10000;
		opacity: 1;
	}

	100% {
		opacity: 0;

	}
}

@keyframes modal_inner_close {
	0% {
		opacity: 1;
		transform: translateY(0);
	}

	100% {
		transform: translateY(-20px);
		opacity: 0;

	}
}
            
          
!

JS

            
              // modalを出す
  const modalOpen = document.querySelectorAll('.modal-open');
  const modal = document.querySelectorAll('.modal');
  const modalCover = document.querySelectorAll('.modal-cover');

  let modalCloseAction;
  let dataModalOpen;
  let targetModal;

  const TIMEOUT_SPEED = 500;

  for (let i = 0; i < modalOpen.length; i++) {
      
      //モーダルを下げる処理
      modalCloseAction = function(e) {
        targetModal = e.currentTarget.closest('.modal');
        targetModal.classList.add('is-close');

        setTimeout(function(e) {
          targetModal.classList.remove('is-open');
          targetModal.classList.remove('is-close');
        }, TIMEOUT_SPEED);
      };
      
      // グレー部分をクリックでmodalを下げる
      const modalWrapClose = function() {
           modalCover[i].addEventListener('click',function(e){
             modalCloseAction(e);
        },false);
      };

      // modalをあげる
      const modalWrapOpen = function(e) {
        dataModalOpen = e.currentTarget.getAttribute('data-modal-open');
        for (var b = 0; b < modal.length; b++) {
        
          if (modal[b].getAttribute('data-modal') === dataModalOpen) {
            modal[b].classList.add('is-open');
            modalWrapClose();
            return false;
          }
        }
      };
      
      modalOpen[i].addEventListener('click', function(e) {
        modalWrapOpen(e);
      }, false);
  }

  // modalを下げる
  const modalBtnClose = document.querySelectorAll('.btn-close');
  for (let n = 0; n < modalBtnClose.length; n++) {
      modalBtnClose[n].addEventListener('click', function(e) {
        modalCloseAction(e);
        return false;
      }, false);
  }
            
          
!
999px

Console