hidden part video, from youtube - css

I have video from youtube, i want hidden some place from this video, this is my code
<div style="width: 200px; height: 315px; overflow: hidden">
<iframe width="560" height="315" src="http://www.youtube.com/embed/AMoLwrarElA" frameborder="0" allowfullscreen></iframe>
</div>
this works good in all browsers, except safari, in safari is visible all video, someone know why?

Try adding a semi-colon at the end of hidden:
overflow:hidden;
Also try adding:
clear:both;
To your div style.

As the image shows, the way to do this is:
body
div (position = absolute, top = iframe.top, right = iframe.right, width = 350px)
iframe (position = absolute or relative, width = 750px)
here absolute positioned div is the red striped area
You can use jquery to get iframes left top right bottom:
<body>
<div class="cover"></div>
<iframe/>
<script>
$(function(){
var top = iframe.top
var right = iframe.right
$("cover")[0].top = top;
$("cover")[0].right = right;
//..
});
</script>
</body>
Sorry I have less time, cannot explain more, if this does not work I will try again

this code decided this problem
<div style="width: 200px; height: 315px; overflow: hidden;">
<object width="560" height="315" style="float:left; overflow: hidden;">
<param name="movie" value="http://www.youtube.com/v/AMoLwrarElA&hl=ru_RU&fs=1&rel=0&border=0"/>
<param name="allowFullScreen" value="true"/>
<param name="allowscriptaccess" value="always"/>
<param name="wmode" value="opaque"/>
<embed src="http://www.youtube.com/v/AMoLwrarElA&hl=ru_RU&fs=1&rel=0&border=0" wmode="opaque" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="315"/>
</object>
</div>

Related

How can I align YouTube embedded video in the center in bootstrap

I am trying to align YouTube embedded video in the center of the page in my bootstrap page. The size of the video is always the same.
My html looks really simple:
<div class="video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/ig3qHRVZRvM" frameborder="0" allowfullscreen=""></iframe>
</div>
I tried different solutions from stackoverflow (which addressed just centering a div, not a video) and the best I was able to came up with was this fiddle.
I already tried solution1, solution2, solution3 but with no result. Another partially successful solution was to use:
width: 50%;
margin: 0 auto;
It worked nicely on desktop, but failed on iPad or a phone (the video went partially outside of a screen). How is it possible to center the video properly in desktop/tablet/phone?
An important thing to note / "Bootstrap" is just a bunch of CSS rules
a fiddle
HTML
<div class="your-centered-div">
<img src="http://placehold.it/1120x630&text=Pretend Video 560x315" alt="" />
</div>
CSS
/* key stuff */
.your-centered-div {
width: 560px; /* you have to have a size or this method doesn't work */
height: 315px; /* think about making these max-width instead - might give you some more responsiveness */
position: absolute; /* positions out of the flow, but according to the nearest parent */
top: 0; right: 0; /* confuse it i guess */
bottom: 0; left: 0;
margin: auto; /* make em equal */
}
Fully working jsFiddle is here.
EDIT
I mostly use this these days:
straight CSS
.centered-thing {
position: absolute;
margin: auto;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
if your use stylus/mixins ( you should... it's the best )
center-center()
absolute()
margin auto
top 50%
left 50%
transform translate(-50%,-50%)
This way... you don't need to know the size of the element - and the translate is based of it's size - So, -50% of itself. Neat.
Youtube uses iframe.
You can simply set it to:
iframe {
display: block;
margin: 0 auto;
}
<iframe style="display: block; margin: auto;" width="560" height="315" src="https://www.youtube.com/embed/ig3qHRVZRvM" frameborder="0" allowfullscreen></iframe>
You dont have to put <iframe> in a parent div at all. You can target exactly youtube iframe with CSS/3:
iframe[src*="//youtube.com/"], iframe[src*="//www.youtube.com/"] {
display: block;
margin: 0 auto;
}
I set the max width for my video to be 100%. On phones the video automatically fits the width of the screen. Since the embedded video is only 560px wide, I just added a 10% left-margin to the iframe, and put a "0" back in for the margin for the mobile CSS (to allow the full width view). I did't want to bother putting a div around every video...
Desktop CSS:
iframe {
margin-left: 10%;
}
Mobile CSS:
iframe {
margin-left: 0;
}
Worked perfect for my blog (Botanical Amy).
Using Bootstrap's built in .center-block class, which sets margin left and right to auto:
<iframe class="center-block" width="560" height="315" src="https://www.youtube.com/embed/ig3qHRVZRvM" frameborder="0" allowfullscreen=""></iframe>
Or using the built in .text-center class, which sets text-align: center:
<div class="text-center">
<iframe width="560" height="315" src="https://www.youtube.com/embed/ig3qHRVZRvM" frameborder="0" allowfullscreen=""></iframe>
</div>
<div>
<iframe id="myFrame" src="https://player.vimeo.com/video/12345678?autoplay=1" width="640" height="360" frameborder="0" allowfullscreen> .
</iframe>
</div>
<script>
function myFunction() {
var wscreen = window.innerWidth;
var hscreen = window.innerHeight;
document.getElementById("myFrame").width = wscreen ;
document.getElementById("myFrame").height = hscreen ;
}
myFunction();
window.addEventListener('resize', function(){ myFunction(); });
</script>
this works on Vimeo adding an id myFrame to the iframe
make iframe with align="middle" and put it in paragraph with style="text-aling:center":
<p style="text-align:center;">
<iframe width="420" height="315" align="middle" src="https://www.youtube.com/embed/YOURVIDEO">
</iframe>
</p>
For a fully responsive IFramed YouTube video, try this:
<div class="blogwidevideo">
<iframe width="854" height="480" style="margin: auto;" src="https://www.youtube-nocookie.com/embed/h5ag-3nnenc" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
.blogwidevideo {
overflow:hidden;
padding-bottom:56.25%;
position:relative;
height:0;
}
.blogwidevideo iframe {
left:10%; //centers for the 80% width - not needed if width is 100%
top:0;
height:80%; //change to 100% if going full width
width:80%;
position:absolute;
}
<center><div class="video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/ig3qHRVZRvM" frameborder="0" allowfullscreen=""></iframe>
</div></center>
It seems to work, is this all you were asking for? I guess you could go about taking longer more involved routes, but this seemed simple enough.
The easiest way is by adding tag, before , open the tag and then close it after closing . As said by others tag is not supported by HTML5, and even your ide would show an error. I'm using VS Code and yes it shows an error, but if you check your website the video would be in the center. Youtube still understands the tag :)

Iframe width and heigth won't change

This iframe's width and height won't change. I want responsive design. Please help.
Now:
<iframe src="http://www.kadinvekadin.net/mod-burclar.php"
frameborder="0"
scrolling="no"
width="300"
height="300">
Modified 500x500 - not working, still 300x300:
<iframe src="http://www.kadinvekadin.net/mod-burclar.php"
frameborder="0"
scrolling="no"
width="500"
height="500">
for a pure CSS solution you need to wrap your iframe around a container and apply styles to it, for more details please see http://andmag.se/2011/11/responsive-embeds/
Another option is using jquery
please take a loom at https://gist.github.com/aarongustafson/1313517
Try this code,
<html>
<body>
<style>
html,body {height:100%;}
.wrapper {width:80%;height:100%;margin:0 auto;background:#CCC}
.iframe1 {position:relative;}
.iframe1 .ratio {display:block;width:100%;height:auto;}
.iframe1 iframe {position:absolute;top:0;left:0;width:100%; height:100%;}
</style>
<div class="wrapper">
<div class="iframe1">
<img class="ratio" src="sometransparentimage.jpg"/>
<iframe src="http://www.kadinvekadin.net/mod-burclar.php" frameborder="0"
allowfullscreen></iframe>
</div>
</div>
</body>
</html>

Setting border-radius of a div containing a .swf file

When we set border-radius of a div, and then set the code background: url(image.png) for the div, then even if the image is greater than the div, the div gets a curved corner. This is because the image is set as background.
But now I face a problem when I want to contain a .swf file inside the div.
Here's the code of the div along with the .swf file contained as object within itself:
<div id="video_container_1" style="height:300px; border: thick; -moz-border-radius: 5px; border-color:#000000">
<object classid="vid:1" codebase="FlashVideos/bride.swf" width="250px" height="300px" style="-moz-border-radius: 5px; border-color:#000000">
<param name="FlashVideos/bride.swf" />
<param name="quality" value="high" />
<embed src="FlashVideos/bride.swf" quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="250" height="300" wmode="transparent">
</embed>
</object>
</div>
Here, I have already set the border-radius as 5 px. I am testing it on Mozilla, that's why I have used -moz-border-radius. But the div isn't getting the curved corner. However if I remove the whole code under <object> tag which contains the .swf filecoding, then the div is having curved corner.
Maybe there is a silly thing I'm not getting. How to get the curved corners?
Try removing the height attribute and adding padding and see what results that gives.
Example:
<div id="video_container_1" style="padding: 3px; border: thick; -moz-border-radius: 5px; border-color:#000000">
<object classid="vid:1" codebase="FlashVideos/bride.swf" width="250px" height="300px" style="-moz-border-radius: 5px; border-color:#000000">
<param name="FlashVideos/bride.swf" />
<param name="quality" value="high" />
<embed src="FlashVideos/bride.swf" quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="250" height="300" wmode="transparent">
</embed>
</object>
</div>
Try adding/modding this into your style attribute for the container div:
overflow: hidden; height: 300px; width: 250px; border: 5px solid #000;
Grant the container with a padding corresponds to the border-radius, like so:
<div id="video_container_1" style="-moz-border-radius: 5px; padding: 3px;">
<!-- ... -->
</div>
It worked for me with jw5 player just by putting border-radius specifications on the container div, adjusting height and width as necessary, and specifying overflow:hidden;
I did not need to use any padding.

Flex 3, iFrame, Scrollbars

I'm using an iFrame in a Flex 3 project. The problem is that if the user opens my site in a small browser window, they don't get scrollbars. How can I solve this problem? Is there a way to force the browser to put up scrollbars?
If I set the main app to horizontalScrollPolicy="on" verticalScrollPolicy="on" or to "auto", then as you scroll down, the iFrame is stuck to the top of the browser window and obscures the content.
In the main app:
In the Application tag, I've got:
horizontalScrollPolicy="off" verticalScrollPolicy="off"
My iFrame looks like:
<flexiframe:IFrame id="myiFrame" source="http://www.mysite.com/myStuff.html" x="315" y="20" width="498" height="65" scrollPolicy="off" />
In the HTML Template, I've put a div around the swf and added css:
<style type="text/css">
#blockwrapper{
display: block;
margin:0;
padding:0;
width: 980px;
height: 800px;
}
</style>
<div id="blockwrapper">
<noscript>
<object classid="clsid:D26CDA6E-AE6D-11cf-96B8-444553540000"
id="${application}" width="${width}" height="${height}"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="${swf}.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="${bgcolor}" />
<param name="allowScriptAccess" value="sameDomain" />
<embed src="${swf}.swf" quality="high" bgcolor="${bgcolor}"
width="${width}" height="${height}" name="${application}" align="middle"
play="true"
loop="false"
quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>
</noscript>
</div>
Any suggestions?
Thank you.
I've got it working. Below is what I had to do:
A)
<style>
body { margin: 0px; overflow:scroll }
</style>
<style type="text/css">
#blockwrapper{
display: block;
margin:0;
padding:0;
width: 960px;
height: 800px;
}
</style>
B) I set the flex app's width and height in the Application tag to the same as that in the div.
Thank you.
-Laxmidi

css: youtube positioning issue with ie7!

i'm wrapping a youtube video inside of a div.vidwrapper.
I don't want the video to be visible but just the controls. This works fine in all Browsers but not in IE7. I have no clue what i have to do to position the video inside ov my .vidwrapper div in IE7.
html
<div class="vidwrapper">
<object class="video" width="308" height="100">
<embed src="http://www.youtube.com/watch?v=1QP-SIW6iKY" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="308" height="100" wmode="opaque"></embed>
</object>
</div>
css
/*VIDEO*/
.vidwrapper {
width:308px;
height:25px;
overflow:hidden;
position:relative;
}
.video {
bottom:0px;
position:absolute;
}
Here is an example http://jsfiddle.net/3n3C7/ Check this out in any modern browser and then check it out in IE7. I want only the controls to be visible in IE7.
Any idea how i could make that happen?
Try to use _height:21px; this should work.As i am not on Windows so this is probably my guess, but it works most of the time.
What about this?
<iframe title="YouTube video player" width="480" height="25" src="http://www.youtube.com/embed/riW4W66ptqI" frameborder="0" allowfullscreen></iframe>

Resources