- This topic is empty.
-
AuthorPosts
-
July 16, 2014 at 8:47 am #175570cutty382Participant
Hi I am creating a simple application for a homepage. It has three buttons 1|2|3 that you will be able to use to choose a video.
What I have at the moment is a DIV Holder that has the overflow hidden. Then the video DIV which has three videos embedded from YouTube. What I want to happen is have the video DIV move left or right based on which button you choose.
I was trying to work from a piece of code I used for a hover state of a button so I know this code is way off at the moment. But I am thinking there is a quick way to fix this, I just can’t find it.
<style type=”text/css”>
#holder {
width: 320px;
height: 180px;
overflow:hidden;}
#vid{
display:block;
width:320px;
height:180px;
}#vid:hover {
position:relative;
left: -320px;}
</style>
</head>
<body>
Patient Testimonials 1|2|3<iframe width=”320″ height=”180″ src=”//www.youtube.com/embed/Ms5HNwJWVRU?rel=0″ frameborder=”0″ allowfullscreen></iframe><iframe width=”320″ height=”180″ src=”//www.youtube.com/embed/Bt0qUX5YoHM?rel=0″ frameborder=”0″ allowfullscreen></iframe><iframe width=”320″ height=”180″ src=”//www.youtube.com/embed/elkOTaFCHJE?rel=0″ frameborder=”0″ allowfullscreen></iframe></body>
July 16, 2014 at 9:21 am #175572bearheadParticipantI think the most straight forward way to do this is just to create a slide show with the three videos embedded in it.
look into using either:
the anythingslider
or
the flexsliderthen you can just embed the videos into the slider like so:
<div class="yoursliderclass"> <ul class="slideclass"> <li> <embed width="x" height="x" src="viedo1" type="application/x-shockwave-flash"> </li> <li> <embed width="x" height="x" src="viedo2" type="application/x-shockwave-flash"> </li> <li> <embed width="x" height="x" src="viedo3" type="application/x-shockwave-flash"> </li> </ul> </div>
Hope that helps!
July 16, 2014 at 9:32 am #175574SenffParticipantI see what you’re trying to do here but you may want to use a little bit of JavaScript.
(If anything, just to avoid having multiple videos playing at once when you switch in the middle of a video.)
This maybe? http://codepen.io/senff/pen/qjigw
July 16, 2014 at 10:23 am #175579cutty382ParticipantThanks bearhead I am still looking into using a slider.
July 16, 2014 at 10:24 am #175580cutty382ParticipantThanks Senff I like what the code you wrote is trying to do but I can’t get any of the videos to load. Am I missing something? Here is my implementation of your code…
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title></title> <script type="text/javascript"> $('.switch').on('click', function(e){ theurl = $(this).attr('data-uri'); $('.player').attr('src',theurl); e.preventDefault(); }); </script> <style type="text/css"> .player { width:320px; height:180px; background:#c0c0c0; float:none; } ul, li { list-style-type:none; margin:0; padding:0; } li { float:left; margin-left:10px; padding-left:10px; border-left:solid 1px #000; } li:first-child { border-left:0; margin-left:0; padding-left:0; } </style> </head> <body> <iframe class="player" width="320" height="180" src="" frameborder="0" allowfullscreen></iframe></div> <ul> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> </ul> </body>
July 16, 2014 at 12:56 pm #175593SenffParticipantYou’ve missed some code in the 1-2-3 links. You have:
<ul> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> </ul>
You should have:
<ul> <li><a class="switch" href="#" data-uri="//www.youtube.com/embed/Ms5HNwJWVRU?rel=0&autoplay=1">1</a></li> <li><a class="switch" href="#" data-uri="//www.youtube.com/embed/Bt0qUX5YoHM?rel=0&autoplay=1">2</a></li> <li><a class="switch" href="#" data-uri="//www.youtube.com/embed/elkOTaFCHJE?rel=0&autoplay=1">3</a></li> </ul>
July 16, 2014 at 1:24 pm #175606cutty382ParticipantThanks for your quick reply. I still can’t seem to get it to work. Here is the live site I am using to test.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.