Solved

Make youtube video smaller, move position

Posted on 2013-10-23
8
271 Views
Last Modified: 2013-10-24
rockypointendoscopy.com/appendicitis.html

Hi all, If you scroll down to the bottom of the screen, you'll see an image for a youtube video. If you click on it, you'll see a large screen, and the word CLOSE to the right.

I'd like the video to be 50% of the size it is now, but still be close to the word CLOSE, so people will know how to back out of it if they like. Need help again! Thanks in advance.
0
Comment
Question by:mel200
  • 5
  • 3
8 Comments
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39596622
Let's review:

You have a div with id="video_container"
inside which you have another div for closing
and an iframe for displaying the video

Use the following css rules:
#video_container {
    height: 100%;
    left: 0;
    position: absolute;
    top: 120px;
    width: 100%;
}


#video_container > iframe {
    float: right;
    height: 50%;
    padding-right: 30px;
    width: 50%;
}

#video_container > div{
    cursor: pointer;
    float: right;
    padding-right: 30px;
}

Open in new window


and the following html:
<div id="video_container">
<div onclick="document.getElementById('video_container').innerHTML=''">CLOSE</div><br>
<iframe frameborder="0" src="http://www.youtube.com/embed/M2_VvTc2nOg?version=3&amp;autoplay=1"></iframe>
</div>

Open in new window

0
 

Author Comment

by:mel200
ID: 39597098
That works except I lose the pop-up aspect, which is also important. So I want a small image, http://img.youtube.com/vi/M2_VvTc2nOg/1.jpg, to be on the page, and when I click on that, I want the video to appear just as you have it.
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39597259
Add this to your style #video_container style:
display: none;

replace
function big_yt(yt_container,url)
{
document.getElementById(yt_container).innerHTML='<div style="position: absolute; left: 150px; top: 100px; right: 50px; bottom: 80px"><div style="position: relative; float: right; cursor: pointer" onclick="document.getElementById(\''+yt_container+'\').innerHTML=\'\'">CLOSE<\/div><br><iframe src="'+url+'" style="position: absolute; width: 100%; height: 100%" frameborder="0"><\/iframe><\/div>'
} 

Open in new window


with:
var vc = document.getElementById('video_container');

function yt_show()
{
  vc.innerHTML = '<div onclick="yt_hide()">CLOSE</div><br><iframe frameborder="0" src="http://www.youtube.com/embed/M2_VvTc2nOg?version=3&amp;autoplay=1"></iframe>';                                            
  vc.style.display = 'block';	
}

function yt_hide()
{
	vc.innerHTML = '';
	vc.style.display = 'none';
}

Open in new window



Change this:
<a onclick="big_yt('video_container','http://www.youtube.com/embed/M2_VvTc2nOg?version=3&amp;autoplay=1')"><img width="90" height="70" style="cursor: pointer" alt="" title="Appendicitis Operation" src="http://img.youtube.com/vi/M2_VvTc2nOg/1.jpg"></a>

Open in new window


to
<a onclick="yt_show()"><img width="90" height="70" style="cursor: pointer" alt="" title="Appendicitis Operation" src="http://img.youtube.com/vi/M2_VvTc2nOg/1.jpg"></a>

Open in new window

0
 

Author Comment

by:mel200
ID: 39597583
I've done that, and oddly it seems to make everything on the page un-clickable, including the youtube image.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 14

Accepted Solution

by:
Pierre Cornelius earned 500 total points
ID: 39597598
the video_container div is lying over it all, you need to make sure you have it's style set to "none" to begin with.

You did not change it. Should be like this:
#video_container {
    height: 100%;
    left: 0;
    position: absolute;
    top: 120px;
    width: 100%;
    display: none;
}

Open in new window


Another thing, seems I got my scope a bit wrong.

Change the functions as follows:
function yt_show()
{
  var vc = document.getElementById('video_container');
  vc.innerHTML = '<div onclick="yt_hide()">CLOSE</div><br><iframe frameborder="0" src="http://www.youtube.com/embed/M2_VvTc2nOg?version=3&amp;autoplay=1"></iframe>';                                            
  vc.style.display = 'block';	
}

function yt_hide()
{
    var vc = document.getElementById('video_container');
	vc.innerHTML = '';
	vc.style.display = 'none';
}

Open in new window

0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39597812
Why not make like an overlay centered and 50% of width and height. Try this, see what you think:

#video_container {
    background-color: #000000;
    height: 100%;
    left: 0;
    opacity: 0.5;
    padding-top: 120px;
    position: absolute;
    top: 0;
    width: 100%;
}


#video_container > div {
    color: #FFFFFF;
    cursor: pointer;
    height: 50%;
    margin: 0 auto;
    text-align: right;
    width: 50%;
}

#video_container iframe {
    height: 100%;
    width: 100%;
}

and changed this (in the yt_show function):
vc.innerHTML = '<div onclick="yt_hide()">CLOSE</div><br><iframe frameborder="0" src="http://www.youtube.com/embed/M2_VvTc2nOg?version=3&amp;autoplay=1"></iframe>';    

Open in new window

                                     
to this:
vc.innerHTML = '<div onclick="yt_hide()">CLOSE<br><iframe frameborder="0" src="http://www.youtube.com/embed/M2_VvTc2nOg?version=3&amp;autoplay=1"></iframe></div>';

Open in new window

0
 

Author Closing Comment

by:mel200
ID: 39597994
That works, thanks very much!
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39598079
You're welcome. Good luck
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now