Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Grant Bates
Grant Bates
1,915 Points

Stuck creating a 468x60 Static image that reveals a 640x360 video that autoplays at roll-over.

I created a fiddle to show what I am stuck on.

http://jsfiddle.net/austincarnivore/f1o6fhzz/

Anyone know how to put this video inside the hover/reveal effect? I would prefer to keep it all html & css if possible.

1 Answer

Codin - Codesmite
Codin - Codesmite
8,600 Points

I don't think it is possible to autoplay on hover without using javascript of jquery becuase I don't think there is anyway to modify the video controls from html or css. You could hide the video but it will be autoplaying while hidden which I guess will not give you the outcome you are hoping for.

The Jquery method is quite simple though:

$("video").bind('mouseenter', function() {
$(this).play();
});

You could have a fallback stylesheet for people without javascript supported browsers that adds a play button instead when hovering.