Can anyone tell me why this isn't responsive? - html

working on a site and this animation isn't responsive. I've changed the width to 100% and added css. Can anyone help me out? here's the site link..
armani.globerunnerstaging.com
Here's my html and css
<div class="video-container">
<iframesrc="https://content.understand.com/hair-loss-dallas.player?PresentationID=4e9e3cad-0f79-49c0-a204-8193a6a4264b&CatalogID=3fcc6564-3065-4b92-a116-8a692f3572d5" width="100%" height="557" frameborder="0" scrolling="no">
</iframe>
</div>
.video-container {
position: relative;
padding-bottom: 65.25%;
padding-top: 30px;
height: 0;
overflow: auto;
-webkit-overflow-scrolling:touch;
border: solid black 1px;
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

First thing, an iFrame can't have a percentage unit for the width attribute :
width="100%" height="557" frameborder="0"
It should be pixels. For example:
width="701" or width="701px"
But your main problem is that player displaying within your iFrame has a container with a fixed width of 701px.
div#container
{
background: #FFF;
margin: 0 auto;
padding: 0;
width: 701px;
height: 557px;
}
This means even if your iFrame has a smaller width than 701px, its content won't shrink below that limit.
Unless you can edit the CSS of the page inside the iFrame, there is no way to change this behaviour.
UPDATE:
Maybe if you try playing around with CSS Scale transform you could make it work for mobile.
.video-container iframe{
-ms-transform-origin: 0 0; /* IE 9 */
-webkit-transform-origin: 0 0; /* Chrome, Safari, Opera */
transform-origin: 0 0;
-ms-transform: scale(0.75); /* IE 9 */
-webkit-transform: scale(0.75); /* Safari */
transform: scale(0.75);
}
Make sure you correct the iframe property width:"100%" first.
Here is an example : http://codepen.io/Rubecula/pen/CtKdH

Related

Bootstrap div height won't resize properly with video background

I have a video playing in the background of my top div. It looks fine when the screen is full size, but when I resize the browser window to see how it will look on smaller screens, the height of the div remains the same, leaving a big empty space between the background video and the next div.
Here is a preview of the site if you'd like to see for yourself, along with the specific code. https://codepen.io/CarlyWysocki/pen/YYaBOd
HTML:
<div class="jumbotron" id="top">
<video autoplay loop>
<source src="https://videos2.sendvid.com/03/25/up5p1yhu.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
<div class="container text-center">
<h1>Mac Demarco</h1>
<h4>Canadian singer-songwriter, multi-instrumentalist and producer.</h4>
<i class="fa fa-chevron-circle-down"></i>
</div>
</div>
CSS:
video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: auto;
}
.jumbotron {
padding-top: 30px;
padding-bottom: 30px;
margin-bottom: 30px;
color: inherit;
background-color: #eee;
height: 100%;
overflow: hidden;
position: relative;
}
.container {
position: relative;
}
If it just stays in the center, you can add css media queries resizing appropriately. One could also just use a picture for small screens via media queries.
Using the referenced stack overflow answer:
.video-container {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
.video-container video {
/* Make video to at least 100% wide and tall */
min-width: 100%;
min-height: 100%;
/* Setting width & height to auto prevents the browser from stretching or squishing the video */
width: auto;
height: auto;
/* Center the video */
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}

How to fit iframe content with landscape orientation within device screen

I have a webpage that I have set to have a landscape orientation on mobile devices within which I have placed an iframe. My problem is I cant get the iframe to fit within the mobile device screen while in landscape orientation (full width and height matching the device screen). How may I be able to achieve this?
I am using CSS:
<style>
body, html {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
#content {
position:absolute;
left: 0;
right: 0;
bottom: 0;
top: 0
}
#content iframe{
width:100%;
height:100%;
border:none;
}
#media screen and (orientation:portrait) {
body {
-webkit-transform: rotate(-90deg);
-webkit-transform-origin: 50% 50%;
transform: rotate(-90deg);
transform-origin: 50% 50%;
}
}
</style>
And HTML:
<div id="content">
<iframe src="localhost/iframeTest/index.php"
allowtransparency="true" frameborder="0" scrolling="no"
class="wistia_embed" name="wistia_embed" allowfullscreen
mozallowfullscreen webkitallowfullscreen oallowfullscreen
msallowfullscreen width="100%" height="100%"></iframe>
</div>
As I stated in my comment the problem is, that the size is calculated before you rotate it. To fix this you can use vh, vw sizes and just just vw for height and vh for width. Then you can rotate and translate it back into viewport.
body {
display: block;
width: 100vh;
height: 100vw;
transform: translateY(100vh) rotate(-90deg);
transform-origin: top left;
}
Check this codepen to see it working: https://codepen.io/pixelarbeit/pen/rpLbNe

Cover-Video in banner element: always centered and full-width and height

I know there are a lot of questions out there regarding this topic, however I couldn't find a proper solution.
I have a #banner element on top of my site that is 710px high.
In this #banner I have my video that should always scale like "background-size:cover". It doesn't matter if the video is cut at the top or bottom, it should just always fill the #banner element.
#banner {
position:relative;
opacity:0;
height:710px;
width:100%;
overflow:hidden;
}
#banner .video {
position: absolute;
bottom: 50%;
right: 50%;
transform: translateX(-50%) translateY(-50%);
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
overflow: hidden;
}
I found this code right here but it doesn't properly work for me. The video does not resize when scaling the browser-window. For me this does not work.
Also I tried to use the covervid plugin that seems to work perfect for full-background sizes but not to fit it inside a banner with fixed height.
If I use this plugin and resize the window it jumps from width to height fitting, always setting the width or either height to auto.
Any idea how to do this via css or js?
Just remove the opacity from the banner and add max-height:100% to make sure that there's no vertical scroll
DEMO
html,
body {
margin: 0;
height: 100%;
}
#banner {
position: relative;
height: 710px;
border: 5px solid tomato;
overflow: hidden;
max-height: 100%;
box-sizing: border-box;
}
#banner .video {
min-width: 100%;
min-height: 100%;
}
<div id="banner">
<video class="video" autoplay>
<source src="http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4" type="video/mp4" />
</video>
</div>

Force iframe YouTube video to center fit and full cover the screen in the background using HTML5 CSS3

How do you force HTML5 iframe YouTube video to center fit, cover the full-screen window background using CSS3 HTML eventually Java?
As for example "paypal.it" home page background or "unity3d.com/5" top video, has as iframe youtube video.
The iframe covers the full screen (zooming) and covers all the width and height when re-size the window.
It re-size maintaining the 100% min-width zooming the height or the 100% min-height zooming the width.
How is this effect achieve using iframe HTML5 and CSS3?
Code Example HTML5
<div class="video" style="opacity: 1;">
<iframe src="http://www.youtube.com/embed/AddHereVideoId?autoplay=1&html5=1" frameborder="0" style="height: 720px;">
</iframe>
</div>
Code CSS3 HTML eventually Java help would be appreciated.
Full-size YouTube video, all aspect ratios, CSS only
TL:DR - working fiddle
As an update/improvement to #Hinrich's answer, I have created a CSS-only scaler that works for ALL aspect ratios - even the extremes. Rather than over-compensating the width to fit most screen sizes, the iframe is set using vw and vh and offset using the CSS transform property (which offsets relative to the element, not the parent).
Most browsers (IE9+ and all evergreen browsers AFAIK) support the vw and vh units, as well as transforms, so this should work for pretty much all browsers with no JavaScript required.
.video-background {
position: relative;
overflow: hidden;
width: 100vw;
height: 100vh;
}
.video-background iframe {
position: absolute;
top: 50%;
left: 50%;
width: 100vw;
height: 100vh;
transform: translate(-50%, -50%);
}
#media (min-aspect-ratio: 16/9) {
.video-background iframe {
/* height = 100 * (9 / 16) = 56.25 */
height: 56.25vw;
}
}
#media (max-aspect-ratio: 16/9) {
.video-background iframe {
/* width = 100 / (9 / 16) = 177.777777 */
width: 177.78vh;
}
}
<div class="video-background">
<iframe src="https://www.youtube.com/embed/biWk-QLWY7U?controls=0&showinfo=0&rel=0&autoplay=1&loop=1&mute=1" frameborder="0" allowfullscreen></iframe>
</div>
With CSS variables
For those using CSS variables, you can also do this (fiddle), which lets you arbitrarily reuse the sizes for multiple classnames:
:root {
--video-width: 100vw;
--video-height: 100vh;
}
#media (min-aspect-ratio: 16/9) {
:root {
--video-height: 56.25vw;
}
}
#media (max-aspect-ratio: 16/9) {
:root {
--video-width: 177.78vh;
}
}
.video-background {
position: relative;
overflow: hidden;
width: 100vw;
height: 100vh;
}
.video-background iframe {
position: absolute;
top: 50%;
left: 50%;
width: var(--video-width);
height: var(--video-height);
transform: translate(-50%, -50%);
}
For a real full screen solution, this can be achieved like this:
HTML
<div class="video-background">
<div class="video-foreground">
<iframe src="https://www.youtube.com/embed/I4agXcHLySs?controls=0&showinfo=0&rel=0&autoplay=1&loop=1&mute=1" frameborder="0" allowfullscreen></iframe>
</div>
</div>
CSS
* { box-sizing: border-box; }
.video-background {
background: #000;
position: fixed;
top: 0; right: 0; bottom: 0; left: 0;
z-index: -99;
}
.video-foreground,
.video-background iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
#media (min-aspect-ratio: 16/9) {
.video-foreground { height: 300%; top: -100%; }
}
#media (max-aspect-ratio: 16/9) {
.video-foreground { width: 300%; left: -100%; }
}
#media all and (max-width: 600px) {
.vid-info { width: 50%; padding: .5rem; }
.vid-info h1 { margin-bottom: .2rem; }
}
#media all and (max-width: 500px) {
.vid-info .acronym { display: none; }
}
It is not perfect, e.g. it does not work well with extreme aspect ratios of the container, but is doing a great job in most situations. Here is a working example:
https://codepen.io/hnrchrdl/pen/YzPwjBV
Edit: Check Oliver's answer, he seems to have an improved version of this solution.
I think this is what you're trying to achieve:
.video-wrapper {position: relative; padding-bottom: 56.25%; /* 16:9 */ padding-top: 25px;}
.video-wrapper iframe {position: absolute; top: 0; left: 0; width: 100%; height: 100%;}
<div class="video-wrapper">
<iframe src="http://www.youtube.com/embed/AddHereVideoId?autoplay=1&html5=1" frameborder="0" allowfullscreen></iframe>
</div>
This will give you a video that fills the container that it is in and will automatically scale the height too.
I originally found this solution here: https://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php

Full page cropped video in HTML5 - no jquery

I'm trying to add a video in the background of my website. I want to do this without any javascript to optimize the loading time.
So far, I used this code:
HTML:
<video id="video_background" preload="auto" autoplay="true" loop="loop" muted="muted" volume="0" poster="img/video-poster.jpg" >
<img src="img/video-poster.jpg" alt=""/>
<source type="video/mp4" src="video/video.mp4"/>
<source type="video/ogg" src="video/video.ogv"/>
</video>
CSS:
#video_background {
position: absolute;
bottom: 0px;
right: 0px;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -1000;
overflow: hidden
}
The problem is that my video has a panoramic format (16/9) with black margins on top and bottom. Obviously I don't want them to appear on the screen. So with this code, the blacks margin appear on the bottom of the page.
How can I make sure the black margins are cropped and still have a responsive display?
Thanks
There may be a better option out there but I find this to be an elegant solution in my eyes.
I gave the video #video-background a scale(1.09) which would zoom the video in ever so slightly to remove the borders.
I also added this to the html and body to disable the video from going under the fold. This is optional but you will have the bottom border without it.
html, body {
height: 100%;
width: 100%;
position: fixed;
margin: 0;
padding: 0;
}
The css for your video,
#video-background {
position: absolute;
top: 0px;
right: 0px;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -1000;
overflow: hidden;
transform: scale(1.09);
-webkit-transform: scale(1.09);
-moz-transform: scale(1.09);
-o-transform: scale(1.09);
}
Finally, here is the JSFIDDLE to show how it looks. In the url, remove /show to see the code.