Minimalist jQuery Modal / Overlay Plugin - Easy Overlay

File Size: 4.55 KB
Views Total: 1298
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Minimalist jQuery Modal / Overlay Plugin - Easy Overlay

Easy Overlay is an ultra-light (~2kb) jQuery plugin used to display any html content of your web page in a full window modal popup.

How to use it:

1. Place your content inside an element with an unique ID.

<div style="display:none" id="overlayContent">
  Content goes here
  <button class="overlay-close" id="overlayClose">X</button>
</div>

2. Create an element that will launch your modal.

<span id="overlayTrigger">Trigger Modal</span>

3. Call the function on the modal container and we're ready to go.

$('#overlayContent').overlay();

4. Style the modal popup whatever you like.

.overlay {
  display: block !important;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  position: fixed;
  padding: 20px;
  left: 50%;
  top: 60px;
  transform: translate(-50%, 0);
  width: 98%;
  min-height: 100px;
  max-height: calc(98% - 60px);
  z-index: 999;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background-color: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
  background-clip: padding-box;
}

.overlay-close {
  cursor: pointer;
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 40px;
  text-align: center;
  border: 0;
  background: rgba(255, 255, 255, 0.8);
  color: black;
  font-weight: 500;
  font-size: 18px;
  line-height: 12px;
  padding: 12px 15px;
  border: 1px solid #e5e5e5;
  border-radius: 5px;
}

button.overlay-close:hover { border: 1px solid #b2b2b2; }

.overlay-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 900;
  background-color: #000000;
  opacity: 0.8;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
}

5. Default plugin settings.

$('#overlayContent').overlay({

  // CSS id for trigger element
  overlayTriggerId: "#overlayTrigger",

  // CSS id for close element
  overlayCloseId: "#overlayClose"
  
});

Change log:

2015-10-22

  • bugfix.

This awesome jQuery plugin is developed by leolux. For more Advanced Usages, please check the demo page or visit the official website.