I am trying to play a certain video inside a PNG image of an iPhone. The iPhone is serving as a frame for the video. I was able to achieve this using this CSS code:
#phone_container {
width: 343px;
/* Adjust Phone image width */
height: 663px;
/* Adjust Phone image height */
position: relative;
}
#phone_container:after {
content: '';
display: block;
background: url('iphone png link') no-repeat top left transparent;
width: 100%;
height: 100%;
left: 0px;
top: 0px;
position: absolute;
z-index: 10;
}
#video-placeholder {
position: absolute;
top: 125px;
/* Adjust top position */
left: 55px;
/* Adjust left position */
z-index: 5;
}
I was also able to achieve this using this HTML code:
<div class="row demo-video">
<div class="col-md-5 left-side" id="phone_container">
<div>
<iframe id="video-placeholder" src="Video Link" width="270" height="464" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
Although it is working perfectly fine, the only problem is that since the z-index of the iframe is less than the image. The Vimeo player controls are not working. I tried setting the z-index of the player controls higher than that of the iPhone but it's still not working. It's also not responsive. How do I fix this problem? Any suggestions?
Create a div element and set its width and height attributes in CSS. Then apply the background-image for that div. Then you can try to embed the vimeo video within that div:
<div class="vimeo-video">
<!-- vimeo embed link with appropriate width and height //-->
</div>
Add CSS like this:
.vimeo-video {
background-image: url('link-to-png.png');
background-attachment: fixed;
background-repeat: no-repeat;
background-size: 100% 100%;
padding-top: /* play around with this to fit the video */;
padding-bottom: /* play around with this to fit the video */;
padding-left: /* play around with this to fit the video */;
padding-right: /* play around with this to fit the video */;
}
Keep padding values in percentages to enable a responsive design.
Related
I am trying to make my responsive embedded youtube video not appear so large on a regular desktop display. It looks fine in mobile, but when trying to adjust the size to make it look good on desktop it ruins the responsive on mobile.
I've tried adjusting the width / height % in css which allows me to resize in desktop but ruins the responsiveness in mobile.
.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px; height: 0; overflow: hidden;
}
.video-container iframe,
.video-container object,
.video-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
<div class="video-container">
<iframe width="853" height="480" src="https://www.youtube.com/embed/z9Ul9ccDOqE" frameborder="0" allowfullscreen>
</iframe>
</div>
I am trying to get my embedded video to look like a normal sized video but yet responsive. Currently it takes up the entire screen.
here is a photo of the desktop display.
Use the max-width CSS property to set a hard limit for where you want the video to stop expanding. That way, if the user is using something such as an ultrawide monitor, your content will cap where you want it to.
Here's an example:
.expandable{
width: 80%
max-width: 1200px;
}
I'm building a website and the two videos I'm using overlap and I can't figure out why. I'm using two classes and I've taken out the top and left and it still over laps. I'm also curious why instead of the video being small the video is being cut out. the video will either play the top half or the bottom half of the video but my actually question is why the two videos overlap and how can I fix it.
#media only screen and (max-device-width:480px) {
/* styles for mobile browsers smaller than 480px; (iPhone) */
.center {
width: 300px;
height: 100px;
position: fixed;
/*left: 48.5%;
top: 44%;*/
transform: translate(-50%, -50%);
}
.embed-container {
position: relative;
width: 100%;
height: 0;
padding-bottom: 56.27198%;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
}
}
.embed-container iframe {
position: absolute;
width: 50%;
height: 50%
}
<!--stackover flow trying to get the videos to shirnk when using mobile devices. need to be done for "ipad" and cell phones from my knowlegde computers are fine. -->
<p align="center">
<div class="embed-container">
<iframe src="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Fwhereisslice%2Fvideos%2F1034464440067039%2F&show_text=0&width=560">
</iframe>
</div>
</p>
<p align="center">
<div class="embed-container">
<iframe src="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2FTimeOutForMeInc%2Fvideos%2F526931557744638%2F&show_text=0&width=267">
</iframe>
</div>
</p>
To answer your first question looks like you have the videos set to position absolute. Removing that position rule from the class .embed-container iframe will get the videos stacked on top of each other.
Why the videos themselves are being cut off is because you are constraining the hight property in .embed-container iframe as well. If you inspect the video play in the iFrame you will notice that Facebook is giving it a set pixel hight. You ought to be able to fix this by removing your set height in .embed-container iframe
I am in the midst of figuring out if there are other methods/techniques on how you can fit a background video that has large aspect ratios to be seen in full on landing page without getting cropped. Right now, the only solution i have found was to add object-fit:cover to the video element. It did the trick. However, its not compatible to Internet explorer. The true aspect ratio of the video I'm using is 3840X2160. I already tried adding width and height property in viewport to the parent element but it didn't work.
Below is my current code.
HTML
<div class="v-header container">
<div class="fullscreen-video-wrap">
<video src="video1.mp4" autoplay muted loop></video>
</div>
</div>
CURRENT CSS
.fullscreen-video-wrap video{
position: absolute;
min-width: 100%;
min-height: 100%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index:-1;
}
PREVIOUS CSS CODE WITH SOLUTION with object-fit:cover
.fullscreen-video-wrap video{
position:absolute;
top:0;
left: 0;
width:100%;
height:100%;
z-index: -1;
object-fit: cover;
}
Consider trying to use CSS vw (view width) and/or vh (view height). Using these units like I did below, it shouldn't get cropped (although they may have to scroll to see the full height, with it set to auto). I tested your code with an image instead of a video because I don't have a video with that resolution on hand.
.fullscreen-video-wrap video{
position: absolute;
max-width: 100vw;
height: auto;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index:-1;
}
.fullscreen-video{
width:100%;
height:auto;
}
Here's the codepen where I tried it out, so you can play around with the idea:https://codepen.io/gemiller/pen/PXqpYQ . You can also learn more about vh/vw here: https://www.w3schools.com/cssref/css_units.asp
I'm making responsive video as background. I want this video to be 100vh in height and automatically cropped in width when the user uses vertical device orientation(phone for example) to preserve aspect ratio. Also i want to remove the white bars which you see in the picture below. How to do this?
video{
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
width: 100vw;
}
#media (pointer:coarse) {
#media (hover: none), (hover:on-demand) {
video {
height:100vh;
}
}
}
<video src="http://techslides.com/demos/sample-videos/small.mp4" autoplay muted loop></video>
I don't know if your background-approach works with videos, but you can do this:
<video id="video">
<source/>
</video>
and
#video{
position: fixed;
right: 0;
bottom:0;
min-width: 100%;
min-height: 100%;
}
This will result in full-screen video that gets cropped when the parent-container has different ratio.
If you want to use it as background, just use another container with fixed-position for the content. You can find a full example here: https://www.w3schools.com/howto/howto_css_fullscreen_video.asp
This question already has answers here:
Making an iframe responsive
(24 answers)
Closed 5 years ago.
I'm trying to make a responsive template and I'm using iframes for youtube videos.
When i put a caption underneath the video it works fine on desktop, but when I go to responsive mobile mode there is big between caption and video.
Can any body help me to fix it, so that caption stay underneath the video regardless wether I'm on desktop or mobile.
Here is the link for my template:
http://www.sayarts.com/past-events.html
You are not using the right approach to make your videos responsive. Height for your videos remain fixed that's why their is huge gap between videos and caption on mobile phones.
To make the videos perfectly responsive, add the video inside a div like this:
<div class="videoWrapper">
<!-- Copy & Pasted from YouTube -->
<iframe width="560" height="349" src="http://www.youtube.com/embed/n_dZNLr2cME?rel=0&hd=1" frameborder="0" allowfullscreen></iframe>
</div>
and then use the following CSS:
.videoWrapper {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
}
.videoWrapper iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
You can read more about it in this article
You can simply add this style to the wrapper element: height:auto, it seems to fix the problem.
#wrapper embed, #wrapper iframe {
max-width: 100%;
height: auto;
}
If you need more control use the responsive media queries, this is an example:
#media only screen and (max-width: 468px) {
body {
/*you specific styles*/
}
}