Issue with modal not being able to close the embedded video iframe

I have created a demo of a video in my footer that uses external CSS files and works perfectly.

However, when I added it to the project, everything works except for closing the video. After clicking the play button in the footer, a modal appears on the screen but does not fill the entire screen.

And when I try to close it, the modal closes but the iframe remains visible.

Below is the code snippet:

HTML

<div class="homepage-video">
  <div class="hv-container">
    <div class="hv-player">
      <h3>BruxZir Hammer Test</h3>
      <p>Watch how it holds up to a hammer</p>
      <a href='#' onclick='overlay()'>
        <span class="hv-play">
          <i class="fa fa-play"></i>  
        </span>
      </a>
    </div>
  </div>
</div>


<div id="overlay">
  <div class="featured-video">
    <a href='#' onclick='overlay()'>
      <i class="fa fa-times-circle-o"></i>
    </a>

    <iframe src="//player.vimeo.com/video/88944978" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
  </div>
</div>

CSS

.homepage-video { background-color: black; }
.homepage-video { background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/101702/lab-interior.jpg'); }
.homepage-video {
  background-position: center -60px;
  background-repeat: no-repeat;
}
.homepage-video { background-size: cover; }

.hv-container {
  background-color: rgba(30,30,4, 0.6);
  min-height: 240px;
  position: relative;
}
.hv-player {
  width: 320px;
  max-width: 100%;
  margin: 0 auto;
  position: absolute;
  top: 30px;
  left:0; right: 0;
  padding-top: 20px;
  text-align:center;
}
.hv-player, .hv-player h3, .hv-play { color: #f4f3f3; }
.hv-play {
  border: 3px solid #fff;
  cursor:pointer; 
  padding: 4px 18px;
  border-radius: 13px;
  font-size: 30px
}

/* reset for IE*/
body { height:100%; margin:0; padding:0; }
/* code */
#overlay {
  visibility: hidden;
  position: absolute;
  left: 0px;
  top: 0px;
  width:100%;
  height:100%;
  z-index: 1000;
}

#overlay { background-color: #222;}
/* must have these resets */
html, body{ height: 100%; padding: 0; margin: 0;}

/* code begins*/
.featured-video { height: 100%; width: 100%; }
.featured-video iframe {
  height: 100%;
  width: 100%;
  margin-right: auto; 
  margin-left: auto;
  vertical-align: middle; 
}
#overlay i {
  color: #999;
  font-size: 48px;
  margin: 10px;
}

JS

function overlay() {
  el = document.getElementById("overlay");
  el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
}

Answer №1

Consider using:

display: none
// and
display: block

in place of

visibility: hidden
// and
visibility: visible

The updated demonstration is available here:

http://codepen.io/anon/pen/tBKnc

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error encountered: Invalid symbol detected ('<') while attempting to parse JSON in an Angular application

I am experiencing an issue with my Angular code when trying to submit a form. Upon clicking the submit button, an error saying JSON Parse error: Unrecognized token '<' appears, and empty records are being saved in the database. I have included ...

Adding static JSON array data to the results received from an API call

Within my code snippet below, I am able to retrieve a JSON Response: respArray = [] respArray = respBody.classifiers respBody = respArray if (respBody.length > 0) { respBody = applyPagination(respBody, reqParams.filter, option ...

Retrieve external/parent page

This might be a little confusing, but here's what I've been working on. On my website, I have a main page that uses JQuery.load() to load a secondary php page. The main page's URL is: localhost/piproject/roster.php?id=2 However, when I try ...

What is the best method for sending a JavaScript variable to the server and back again?

I'm currently working on a JavaScript project where I need to build a string. Let's say, for the sake of this example: var cereal = 'my awesome string'; There's also a button on my webpage: <button id="send" type="submit" nam ...

Can Angular 4 experience race conditions?

Here is a snippet of my Angular 4 Service code: @Injectable() export class MyService { private myArray: string[] = []; constructor() { } private calculate(result): void { myArray.length = 0; // Perform calculations and add results to myAr ...

Updating a field in Mongoose by referencing an item from another field that is an array

I have developed an innovative Expense Tracker Application, where users can conveniently manage their expenses through a User Collection containing fields such as Name, Amount, Expenses Array, Incomes Array, and more. The application's database is p ...

Vue 3 project experiencing issue with Bootstrap 5 tabs failing to update upon tab click

Currently, I'm in the process of developing a vue3 application with bootstrap 5. As part of this project, I am implementing tabs. Although I can successfully click on the tabs, I have encountered an issue where the tab-content remains fixed on the ini ...

Tips on quickly validating a form using JavaScript

I've set up a form with 3 text inputs and a validation function that triggers on submit. Here's a snippet of the code: <form action="" method="post" onSubmit="return checkForm(this.form)"> and checkForm(): var pattern_name = /^([a-zA-Z ...

Is it possible to convert an array into an object?

I'm attempting to restructure an array of objects into a new object where the label property serves as the key for multiple arrays containing objects with that same label. Check out this JSBin function I created to map the array, but I'm unsure ...

The development server fails to respond when initializing a new project following the NextJs documentation for an empty project

After consulting the NextJs framework documentation, I meticulously followed the setup instructions to initialize an empty project : mkdir hello-next cd hello-next npm init -y npm install --save react react-dom next mkdir pages Subsequently, I included t ...

Displaying JQuery dialogs briefly show their contents before the page finishes loading

Utilizing jquery 1.10.3, I am creating a dialog that is quite intricate. When I say 'intricate', I mean that the dialog's content includes data from a database, such as dropdown lists populated by the results of database queries, alongside s ...

Issue with Iconify icon not updating when "data-icon" is set using setAttribute()

I'm having trouble trying to animate or replace an icon using the "setAttribute" method. Can someone take a look at my code and help me figure out what's wrong? <!DOCTYPE html> <html> <script src="https://code.iconify.design/1/1 ...

Struggling to generate a Cylinder using three.js

I've been attempting to produce a Cylinder, but unfortunately without any luck. Here's the code I used: geometry02 = new THREE.CylinderGeometry( 20, 100, 100, 1000 ); material02 = new THREE.MeshBasicMaterial({color: 0x0000ff}); cylinder02 = new ...

How to reference 'this' within a d3 callback when using Angular 7

In an Angular directive, I am trying to access a class-level variable inside a callback function. To achieve this, I used an arrow function but the 'this' keyword is still not pointing to the directive. this.itemRects.selectAll('rect') ...

What is the method for performing a synchronous call using Backbone's fetch function?

Is it possible to make a synchronous call using the fetch function in JavaScript? I know with jQuery ajax, you can use {async: false}. Can this option be passed to the fetch function? ...

Changing the context results in the entire component being re-rendered

Currently, I am encountering a challenge where I have two different components within my Layout.js component that need to "share" props with each other. To address this issue, I introduced a ContextProvider named IntegrationProvider. However, a new proble ...

What is the best way to conceal floated elements with overflow in CSS?

How can I ensure that my block container element only displays the content of block elements, cutting off any floated elements that are taller than the parent container? Applying overflow: hidden seemed like a simple solution, but it created a new block f ...

Modify how various classes are shown when hovering over a pseudo class

This is my customized scss code .image-container { position: relative; .delete-image { display: none; position: absolute; top: 0px; right: 0px; } .make-primary { display: none; position: absolute; ...

Troubleshooting problem with CSS alignment within Bootstrap framework

Having trouble with the alignment when using bootstrap CSS. My desired layout is as follows: Place name: dropdownbox Gender (radio-button)Male (radio-button)Female Amount Max: textbox Min: textbox Any advice on how to achieve this? ...

Accessing a hyperlink in an alternative browser

Is there a way to transfer a link from one browser to another? For example, moving a link from Firefox to Chrome or from a Chrome Incognito window to a regular Chrome window. Let me provide more context. I have a webpage that refreshes every second and us ...