2

I am using Featherlight.js attempting to get a lightbox effect. The lightbox should open upon the click of an image, yet the target content of the lightbox is a video not the image that is clicked. (Basically, you click a placeholder image and a youtube video pops up.) However, the youtube video is showing as visible on my page below the image before anything is clicked. How do I make the video invisible, except in the context of the lightbox?

@media all {
 .featherlight {
  display: none;

  /* dimensions: spanning the background from edge to edge */
  position:fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 2147483647; /* z-index needs to be >= elements on the site. */

  /* position: centering content */
  text-align: center;

  /* insures that the ::before pseudo element doesn't force wrap with fixed width content; */
  white-space: nowrap;

  /* styling */
  cursor: pointer;
  background: #333;
  /* IE8 "hack" for nested featherlights */
  background: rgba(0, 0, 0, 0);
 }

 /* support for nested featherlights. Does not work in IE8 (use JS to fix) */
 .featherlight:last-of-type {
  background: rgba(0, 0, 0, 0.8);
 }

 .featherlight:before {
  /* position: trick to center content vertically */
  content: '';
  display: inline-block;
  height: 100%;
  vertical-align: middle;
  margin-right: -0.25em;
 }

 .featherlight .featherlight-content {
  /* make content container for positioned elements (close button) */
  position: relative;

  /* position: centering vertical and horizontal */
  text-align: left;
  vertical-align: middle;
  display: inline-block;

  /* dimensions: cut off images */
  overflow: auto;
  padding: 25px 25px 0;
  border-bottom: 25px solid transparent;

  /* dimensions: handling small or empty content */
  min-width:  30%;

  /* dimensions: handling large content */
  margin-left: 5%;
  margin-right: 5%;
  max-height: 95%;

  /* styling */
  background: #fff;
  cursor: auto;

  /* reset white-space wrapping */
  white-space: normal;
 }

 /* contains the content */
 .featherlight .featherlight-inner {
  /* make sure its visible */
  display: block;
 }

 .featherlight .featherlight-close-icon {
  /* position: centering vertical and horizontal */
  position: absolute;
  z-index: 9999;
  top: 0;
  right: 0;

  /* dimensions: 25px x 25px */
  line-height: 25px;
  width: 25px;

  /* styling */
  cursor: pointer;
  text-align: center;
  font-family: Arial, sans-serif;
  background: #fff; /* Set the background in case it overlaps the content */
  background: rgba(255, 255, 255, 0.3);
  color: #000;
 }


 .featherlight .featherlight-image {
  /* styling */
  width: 100%;
 }


 .featherlight-iframe .featherlight-content {
  /* removed the border for image croping since iframe is edge to edge */
  border-bottom: 0;
  padding: 0;
 }

 .featherlight iframe {
  /* styling */
  border: none;
 }
}

/* handling phones and small screens */
@media only screen and (max-width: 1024px) {
 .featherlight .featherlight-content {
  /* dimensions: maximize lightbox with for small screens */
  margin-left: 10px;
  margin-right: 10px;
  max-height: 98%;

  padding: 10px 10px 0;
  border-bottom: 10px solid transparent;
 }
}
<a class="VideoLink" href="#" data-featherlight="#mylightbox">
    <img class="PopoutClickImage" src="Images/Dyson Extracted/V Click Video.png"/>
</a>
<div id="mylightbox">
    <iframe width="560" height="315" src="https://www.youtube.com/embed/IUnEEi4tM0U?list=PL4VODwvGuSpSPwDCceh4sL9qIX-WF3oiD&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
</div>
Liz
  • 1,369
  • 2
  • 26
  • 61

3 Answers3

5

Ran into this issue as well and the only solution I found is the following:

#popup_code {
  display:none;
}
.featherlight .featherlight-inner {
  display: block !important;
}

popup_code is the id of the content you are presenting in the lightbox. The display:none attribute will make sure the original content is always hidden. Having display:block on the inner element of featherlight will make sure it will display the copy of the content in the lightbox once it's opened.

This solution is not ideal as I had to 'important' that attribute. It works though. Hope someone will suggest a better approach though.

Tomer Shay
  • 771
  • 6
  • 17
0

Then you also have to mark the .featherlight-inner with display:block !important in the featherlight.css otherwise the content will still be hidden. Not the best plugin...

/* contains the content */
.featherlight .featherlight-inner {
    /* make sure its visible */
    display: block !important;
    text-align: center;
}
casiokid
  • 119
  • 9
-1

the featherlight docs are using a class that includes display:none on their lightbox targets. so make a class .hide { display:none } if you don't already have one and add it to #mylightbox.

xeo
  • 807
  • 2
  • 7
  • 25