0

When I hover over the image the play button shows and the background-color and opacity of .youTubeVideo changes.

However, this does not happen when you hover over just the play button. How can I make the background-color and opacity of .youTubeVideo change when hovering over the play button?

.youTubeVideo:hover {
  opacity: 0.5;
  background-color: green;
}
.videoThum:hover {
  background-color: green;
  background-image: url("http://s24.postimg.org/k69rptjk1/play_button.jpg");
  background-position: center top;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
<div class="col-3">
  <div class="videoThum">
    <a href="javascript:;" rel="https://www.youtube.com/embed/OSgvYZpO2xY" class="youTubeVideo">
      <img src="http://s8.postimg.org/jf407d2xh/saina_nehwal_syed.png" />
    </a>
  </div>
  <div class="caption"><a href="#"><h2>2015 Syed Modi International</h2></a>
    <a href="#">
      <p>2015 Syed Modi International India Masters SF [WS]</p>
    </a>
  </div>
</div>

DEMO

Hidden Hobbes
  • 13,893
  • 3
  • 38
  • 64
pcs
  • 1,864
  • 4
  • 25
  • 49

2 Answers2

1

The issue is that when you hover over the right side of .videoThum you are no longer hovering over .youTubeVideo so .youTubeVideo:hover wont take effect.

As .videoThum contains .youTubeVideo you can trigger the change to .youTubeVideo when .videoThum is hovered instead by changing .youTubeVideo:hover to .videoThum:hover .youTubeVideo.

.videoThum:hover {
  background-color: green;
  background-image: url("http://s24.postimg.org/k69rptjk1/play_button.jpg");
  background-position: center top;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.videoThum:hover .youTubeVideo {
  opacity: 0.5;
  background-color: green;
}
<div class="col-3">
  <div class="videoThum">
    <a href="javascript:;" rel="https://www.youtube.com/embed/OSgvYZpO2xY" class="youTubeVideo">
      <img src="http://s8.postimg.org/jf407d2xh/saina_nehwal_syed.png" />
    </a>
  </div>
  <div class="caption"><a href="#"><h2>2015 Syed Modi International</h2></a>
    <a href="#">
      <p>2015 Syed Modi International India Masters SF [WS]</p>
    </a>
  </div>
</div>

JS Fiddle: http://jsfiddle.net/bq9rgzap/

Hidden Hobbes
  • 13,893
  • 3
  • 38
  • 64
  • @saina In that case please check my edit to your question as it may not be exactly what you are after. You may want to roll it back or edit it with extra information. Please could you clarify exactly what it is about my answer that isn't fulfilling your criteria? – Hidden Hobbes May 20 '15 at 09:24
0

Your background image is covering the whole element.

See this modified fiddle with background-size changed to see the problem.

One way around this would be to use a png image with transparency or pseudo elements with position:absolute

See CSS: set background image with opacity?

Community
  • 1
  • 1
AmmarCSE
  • 30,079
  • 5
  • 45
  • 53