Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.