Is there a way to eliminate the hover opacity effect when clicking on the video to prevent transparency?

Is there a way to change the opacity of a YouTube video when hovering over it, but have it stay solid when clicked to play? The current method doesn't seem to be working for me.

I'm having trouble using jQuery and the click function on the iframe. It's not functioning as expected.

* {
  margin: 0px 0 0 0;
}
body {
  background: url("https://photos-4.dropbox.com/t/2/AAAzaQaQL59efVSi-nMxk-jzk3dedLDcqaHBtj9zHmBZ2g/12/20139880/jpeg/32x32/1/_/1/2/back.jpg/EJ6Giw8Y9DUgBygH/bwJw1OSYLtn5ScrUolS8x1brd_phrJ_y11sS9ctVrzQ?size_mode=5") fixed;
  background-size: cover;
}
#content {
  width: 853px;
  height: 480PX;
  background: #000000;
  opacity: 0.8;
  margin-top: 40px;
  margin-left: auto;
  margin-right: auto;
}
iframe {
  opacity: 0.7;
  filter: alpha(opacity=70);
  -moz-transition: all 0.4s ease-out; 
  -o-transition: all 0.4s ease-out; 
  -webkit-transition: all 0.4s ease-out; 
  -ms-transition: all 0.4s ease-out; 
  transition: all 0.4s ease-out;
}
iframe:hover {
  opacity: 1.0;
  filter: alpha(opacity=100);
  -moz-transition: all 0.4s ease-out; 
  -o-transition: all 0.4s ease-out; 
  -webkit-transition: all 0.4s ease-out; 
  -ms-transition: all 0.4s ease-out; 
  transition: all 0.4s ease-out;
}
#logo {
  margin-top: 30px;
  margin-left: auto;
  margin-right: auto;
  opacity: 0.6;
  width: 600px;
  height: auto;
}
#logo img {
  width: 600px;
  height: auto;
}
<div id="logo">
  <img src="http://s277461962.websitehome.co.uk/codepen/logo.png" />
</div>
<div id="content">
  <iframe width="853" height="480" src="https://www.youtube.com/embed/grsCRQaY2CI?rel=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
</div>

CodePen: http://codepen.io/Middi/pen/PGbNgg

Answer №1

To enhance the interactivity of the iframe, consider adding and removing classes...

Give this a try:

.iframe.hover-effect {
    opacity: 1.0;
    filter: alpha(opacity=100);
    -moz-transition: all 0.4s ease-out;
    // additional styles
}

$("iframe").mouseenter(function () {
    $(this).addClass("hover-effect");
}).click(function () {
    $(this).removeClass("hover-effect");
}).mouseleave(function () {
    $(this).addClass("hover-effect");
});

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

How to preserve alternating row styles when exporting Angular Data Table to Excel with .withButtons?

Utilizing Angular DataTable to display a list of data, with alternate row background color and border styles defined. An issue arises when exporting the Data table to excel as the alternate row style and border styles are lost. Only the raw data is includ ...

Does CSS Perspective make lower values appear bigger?

When looking at a cube from different perspectives, as shown in this example: http://codepen.io/HugoGiraudel/pen/GLbca The cube on the right has a perspective of -webkit-perspective: 250px;, while the one on the left has -webkit-perspective: 1000px; Acco ...

How can I detect numeric strings in any input or textarea using an event listener?

Interested in creating a clever script or browser extension that, when the first four digits of my credit card are entered, automatically opens a tab with distracting content like porn to help curb unnecessary spending. Can this innovative solution be im ...

Sending an array of arrays from JavaScript to a Spring MVC controller via AJAX

Having a bit of trouble with passing arrays within arrays. The first example below shows a simple array being passed successfully. However, when attempting to pass an array of arrays in the second example, it doesn't seem to work. Any suggestions on h ...

Tips for changing a fullscreen HTML5 video appearance

I discovered a way to change the appearance of a regular video element using this CSS code: transform: rotate(9deg) !important; But, when I try to make the video fullscreen, the user-agent CSS rules seem to automatically take control: https://i.sstatic. ...

Determine the value of an option based on a different element

Here is the HTML markup I am working with: <div class="wrap_select"> <span class="select" id="selectdateRange">Today, 25 March, Sun</span> <select class="styled" id="dateRange" name="dateRange"> <option value ...

In the process of protecting a comment form and its corresponding API endpoint, it's important to consider where input should be sanitized, validated, and encoded - whether that

I am currently working on enhancing the security of a comment form in a non-CMS environment without user authentication. The goal is to protect the form from both browser and curl/postman type requests. Environment Backend - Node.js, MongoDB Atlas, and ...

Aligning text in a <td> cell within a PHP SQL presentation

I am facing an issue with a table in which data is displayed using SQL and PHP. The problem arises because the second column contains a picture (column named "thumbsrc"), causing the text in the first column (column named "photosrc") to not center itself a ...

Guide to triggering an event when two distinct keys are pressed simultaneously (Using HTML5 and Javascript)

I'm looking to have my character jump whenever I press any key on the keyboard. Is there a method to achieve this using "case..." functions? Thanks! Jordan ...

Create angled corners enclosed by a trim

I'm looking to create an HTML shape with cutoff corners and a border around it. Currently, I can create cutoff shapes without borders using the following code: HTML: <div class="cut-off"></div> CSS: .cut-off{ position:relative; ...

Add one hyperlink after the other

Is there a way to use jQuery to add a hyperlink after another link with specific text? For example, adding a new link after the text "append after me". <div class="links"> <a href="#" class="myLink">some link</a> <a href="#" ...

Unable to retrieve the input value

I'm struggling to retrieve the input value from my form. Despite trying several solutions, I haven't been able to get any results. Here is the code for the form input: <input class="form-control" id="account_ya_price_list_url shop_key_input" ...

The success rate of Jquery Ajax is consistently low

I need to validate whether the number entered by users in an input field on a form is already stored in the database. Form (index.php): <script> function validateNumber(number) { if (number < 1 || number > 100) { alert("Invalid Number!") ...

Height of Nav-Links in Bootstrap 4

Is there a way to modify the height of the navigation links in Bootstrap? To set a specific height, such as for the navbar, you may encounter issues where it doesn't occupy the entire space. CSS CODE: .navLogo { width: 15%; height: 100%; } ...

What could be causing my javascript (jquery) code to malfunction on my website?

Hey there, I'm currently working on my first website design project and I'm experimenting with something new: 1) As the page loads, it displays an image as the background. 2) When a user scrolls down past the image, the menu bar should become f ...

Looking to obtain rendered tree data upon page load?

Is there a way to retrieve all rendered tree metadata when the page loads using jstree? I'm looking for an output similar to this: [23,24] Please note that I would like to have each id stored in the metadata object displayed as [23,24] upon page loa ...

Changing Images with Button Click in Javascript

I am facing an issue with my buttons that should swap images once clicked. The first two buttons work perfectly, but for the third and fourth buttons, the images do not disappear when clicking another button. Below is the current code in the document head ...

Using PHP, jQuery, and HTML to submit a form and insert data into MySQL, all while

I am facing an issue with my PHP intranet site, which includes an HTML form with 2 input fields. My goal is to take the user's input from the form and insert it into a MySQL database without redirecting the user to another page. I have a separate PHP ...

Choose Select2 to remove all selected options

I'm looking for a way to remove all selected values in one click without having to specify each individual 'id' separately. I've tried experimenting with different approaches, but so far, I've only been able to deselect the first ...

The loading of jQuery's 'Galleria' stops unpredictably

The issue at hand revolves around a jQuery gallery known as 'Galleria'. It's visually appealing and since my client is a Photographer, I decided to showcase all of his images in a Galleria gallery. You can view the website, currently in its ...