jquery - 单击时如何删除不透明度(悬停不透明度)以使视频不透明

标签 jquery html css youtube opacity

我希望能够将鼠标悬停在 YouTube 视频上并影响透明度/不透明度(就像现在一样)但是,当我点击播放视频时,它会变成实心并且不再使用悬停不透明度。

我不确定如何在 iframe 上使用 jQuery 和 click 功能。好像不行。

* {
  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;
  /* FF4+ */
  -o-transition: all 0.4s ease-out;
  /* Opera 10.5+ */
  -webkit-transition: all 0.4s ease-out;
  /* Saf3.2+, Chrome */
  -ms-transition: all 0.4s ease-out;
  /* IE10? */
  transition: all 0.4s ease-out;
}
iframe:hover {
  opacity: 1.0;
  filter: alpha(opacity=100);
  -moz-transition: all 0.4s ease-out;
  /* FF4+ */
  -o-transition: all 0.4s ease-out;
  /* Opera 10.5+ */
  -webkit-transition: all 0.4s ease-out;
  /* Saf3.2+, Chrome */
  -ms-transition: all 0.4s ease-out;
  /* IE10? */
  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>

代码笔:http://codepen.io/Middi/pen/PGbNgg

最佳答案

在这里添加和删除类可能是一个不错的选择...

试试这个:

iframe.hoverclass {
    opacity: 1.0;
    filter: alpha(opacity=100);
    -moz-transition: all 0.4s ease-out;
    // etc.
}


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

关于jquery - 单击时如何删除不透明度(悬停不透明度)以使视频不透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39643745/

相关文章:

javascript - 如何让div向下滑动然后立即回到页面

jquery - 在 AngularJS 中创建 JSONP API 并使用 jQuery 进行使用

php - float 框将其他所有内容向下推 - 无限滚动

javascript - 解析标签javascript的html属性

html - CSS 媒体查询顺序问题

css - 为什么这个定价字段 li 会堆叠在移动设备上?

jquery - AJAX WordPress 网址

javascript - JQuery 函数 keyup 在我的项目中不起作用,而其他函数可以工作

html - 使用 CSS,如何在两个 float div 之间堆叠两个跨度?

javascript - 如何将一组元素包裹在 div 内联中?