Minimal Responsive iFrame Popup Plugin For jQuery - WMBox

Minimal Responsive iFrame Popup Plugin For jQuery - WMBox
File Size: 3.84 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

WMBox is an ultra-light (~1kb) jQuery plugin which lets you create a responsive modal popup to display external content like Youtube or Vimeo videos.

How to use it:

1. Include the jQuery WMBox plugin's script after the jQuery JavaScript library as shown below.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="js/wmBox.js"></script>

2. Create a trigger element to open the modal popup and specify the external content to be displayed in the iframe using data-popup attribute.

<a class="wmBox" href="#" 
   data-popup="https://player.vimeo.com/video/85910707?title=0&byline=0&portrait=0&badge=0">
   Play The Video
</a>

3. Initialize the plugin and you're done.

$.wmBox();

4. The required CSS to style the modal popup.

.wmBox_overlay {
  position: fixed;
  width: 100%;
  height: 100%;
  display: none;
  top: 0;
  left: 0;
  background: rgba(0,0,0,0.5);
}

.wmBox_centerWrap {
  display: table;
  position: absolute;
  width: 100%;
  height: 100%;
}

.wmBox_centerer {
  display: table-cell;
  vertical-align: middle;
}

.wmBox_centerer iframe {
  width: 95%;
  display: table;
  margin: 0 auto;
  position: relative;
}

.wmBox_contentWrap {
  width: 50%;
  margin: 0 auto;
  position: relative;
}

.wmBox_scaleWrap {
  position: relative;
  height: 0;
  padding-top: 20px;
  padding-bottom: 56.25%;
  width: 100%;
}

.wmBox_centerer iframe {
  position: absolute;
  top: 0;
  border: 0;
  outline: 0;
  box-shadow: 0px 0px 10px rgba(0,0,0,0.5);
  left: 0;
  width: 100%;
  height: 100%;
}

.wmBox_closeBtn {
  z-index: 2;
  position: relative;
  margin-top: -40px;
}

.wmBox_closeBtn p {
  line-height: 0;
  margin: 0;
  padding: 0.5em 0 0.75em;
  color: #FFF;
  background: #000;
  width: 1.3em;
  font-size: 25px;
  border-radius: 100%;
  text-align: center;
  font-family: Verdana, serif;
  position: relative;
  bottom: -0.5em;
  right: -0.5em;
  cursor: pointer;
  float: right;
  box-shadow: 0px 0px 10px rgba(0,0,0,0.5);
  transition: color 0.2s ease-out, background 0.2s ease-out;
}

.wmBox_closeBtn p:hover {
  background: #FFF;
  color: #000;
}

Change log:

2017-03-27

  • Minimized HTML reconstruction

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