You made the video disappear after you click on it.
This method works too. Still blank after you click on it.
.overlay {
position:absolute;
top:0px;
left:0px;
width:100%;
height:100%;
cursor:pointer;
background-color:black;
border-radius:50px;
border:5px solid #5CB378;
background-image:url('https://i.imgur.com/bQGFmLZ.png');
z-index:1;
<img class="overlay" >
It’s just slightly invalid.
If you take everything out of the fiddle that I just gave you, does the video play? It does not for me, which suggests that something else is wrong, not the test code that I gave you.
Look I just did this,
It resizes but it’s not perfect.
Without this code clicking on it won’t make it start.
<div style="width:650px;display:block;" onclick="thevid=document.getElementById('thevideo');
thevid.style.display='block'; this.style.display='none';
document.getElementById('iframe').src =
document.getElementById('iframe').src.replace('autoplay=0','autoplay=1');">
<img class="overlay" >
<div id="thevideo" style="display: none;">
How would I make it valid if it’s slightly invalid?
Replace <img class="overlay">
with <div class="overlay"></div>
and see if that works or not.
It works, but it’s still blank after you click on it.
This would be the valid code though?
<div class="overlay"></div>
I realise this has moved too far for me to butt in but here;s how I would do it.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
html, body {
height: 100%;
background: #000;
color:#fff;
padding: 0;
margin: 0;
}
.outer {
display: table;
height: 100%;
margin: 0 auto;
width:100%;
}
.tcell {
display: table-cell;
vertical-align: middle;
}
.wrap {
max-width:640px;
position:relative;
margin:auto;
border: 10px solid #5CB378;
border-radius:10px;
}
.inner {
position:relative;
height:0;
padding-bottom:56%;
cursor: pointer;
background-color: black;
}
#thevideo, .image {
position:absolute;
left:0px;
top:0px;
right:0px;
bottom:0px;
height:100%;
width:100%;
background-color:#000000;
cursor: pointer;
}
#thevideo iframe, .image img {
width:100%;
height:100%
}
</style>
</head>
<body>
<div class='outer'>
<div class='tcell'>
<div class="wrap">
<div class="inner">
<div class="image" onclick="thevid=document.getElementById('thevideo');
thevid.style.display='block'; this.style.display='none';
document.getElementById('iframe').src =
document.getElementById('iframe').src.replace('autoplay=0','autoplay=1');"> <img src="https://i.imgur.com/bQGFmLZ.png" ></div>
<div id="thevideo" style="display: none;">
<iframe id="iframe" src="https://www.youtube.com/embed/Hj_91ntoi50?rel=0&disablekb=1&vq=medium&showinfo=0&controls=1&autoplay=0&iv_load_policy=3&fs=0&wmode=transparent"></iframe>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
The iframe will resize but I kept the max-width which can be changed or removed as required.
You can’t really round the corners of a player in an iframe unless you put it underneath a rounded element or add corners on top of it.
How come the corners are rounded here?
Is there any way to do rounded corners with your code?
I din’t see any rounded corners on the player. Indeed I see no player in your fiddle?
Here you go:
http://testpage34567.blogspot.com/
Now do you see?
That is an image with round corners, not an iframe or video player.
Yes i see exactly as I stated that in Chrome there are no rounded corners on the player and they stick out of the iframe corners.
It looks naff!
I won’t uses rounded corners then. Thank you for showing me that.
I want to add this to CSS, how would I do it?
<img src="https://i.imgur.com/bQGFmLZ.png"></div>
Using this: Class, and where do I put it?
<img class="overlay"> or <div class="overlay">
background-image:url('https://i.imgur.com/bQGFmLZ.png');
You want to use that image as a background image?
Yes.
That just seems to be a blue background and Ron has given you the overlay code for it already. In my example you could just set the div itself to blue.
e.g.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
html, body {
height: 100%;
background: #000;
color:#fff;
padding: 0;
margin: 0;
}
.outer {
display: table;
height: 100%;
margin: 0 auto;
width:100%;
}
.tcell {
display: table-cell;
vertical-align: middle;
}
.wrap {
max-width:640px;
position:relative;
margin:auto;
border: 10px solid #5CB378;
border-radius:10px;
}
.inner {
position:relative;
height:0;
padding-bottom:56%;
cursor: pointer;
background-color: black;
}
#thevideo, .image {
position:absolute;
left:0px;
top:0px;
right:0px;
bottom:0px;
height:100%;
width:100%;
background-color:#000000;
cursor: pointer;
overflow:hidden;
}
#thevideo iframe {
width:100%;
height:100%
}
.image {background:blue}
</style>
</head>
<body>
<div class='outer'>
<div class='tcell'>
<div class="wrap">
<div class="inner">
<div class="image" onclick="thevid=document.getElementById('thevideo');
thevid.style.display='block'; this.style.display='none';
document.getElementById('iframe').src =
document.getElementById('iframe').src.replace('autoplay=0','autoplay=1');"> </div>
<div id="thevideo" style="display: none;">
<iframe id="iframe" src="https://www.youtube.com/embed/Hj_91ntoi50?rel=0&disablekb=1&vq=medium&showinfo=0&controls=1&autoplay=0&iv_load_policy=3&fs=0&wmode=transparent"></iframe>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Or if it really is an image then just use a background image and background-size:cover instead of ‘blue’.
I want to use this cause I’m going to change it.
background-image:url('https://i.imgur.com/bQGFmLZ.png');