I'm using an <embed> element so I can render a PDF inline. It works well in all browsers, but I can't figure out how to have the <embed> take up the entire, available height in my Bootstrap column. Here is a Plunker. You'll need to widen the preview pane to see the columns next to each other.
This is my markup:
<div class="container">
<div class="row">
<div class="col-sm-7">
<div id="pdf-container">
<div id="pdf">
<embed width="100%" type="application/pdf" src="http://pdf.pdf">
</div>
</div>
</div>
<div class="col-sm-5">
Other stuff here
</div>
</div>
</div>
And here is the CSS that isn't completely working:
#pdf-container {
bottom: 20px;
left: 20px;
position: absolute;
right: 20px;
top: 0;
}
#pdf-container #pdf {
height: 100%;
width: 100%;
}
What I'm challenged with is that it seems like you need to set the height directly on the '` element so they even render. Setting the width on them to 100% is effective, but I can't get the height to take up 100% of the available height.
UPDATE: There appear to be a series of Bootstrap classes (.embed-responsive) that may be aimed at handling this, but when I apply it, my <embed> doesn't appear at all. Here is a Plunker for that.
I put mine in responsive iframes. Change the padding-bottom and padding-top: 30px; to suit your needs
/* Flexible iFrame */
.Flexible-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
}
.Flexible-container iframe,
.Flexible-container object,
.Flexible-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
<!-- Responsive iFrame -->
<div class="flexible-container">
<object width="100%" data="https://modelica.org/events/modelica2012/authors-guide/example-abstract.pdf?scrollbar=0&toolbar=0&navpanes=0" type="application/pdf">
<embed width="100%" type="application/pdf" src="https://modelica.org/events/modelica2012/authors-guide/example-abstract.pdf?scrollbar=0&toolbar=0&navpanes=0">
</object>
</div>
</div>
Related
I've tried every combination of properties and attributes I can think of to get this iframe to embed in a WordPress post so that all of it is visible on both mobile and large screens. It seems I need to specify a height to get the whole frame to display, but doing so then stops all the width showing on mobile.
Any help much appreciated.
<div markdown="0" id="island">
<iframe style="width: 100%; border: none" scrolling="no" src="http://devonmathstuition.co.uk/dev/treasure-island/"></iframe>
</div>
You need to create your iframe inside another element (with it's position relative), and place your iframe with an absolute position:
The padding-top: 56.25% is useful for keeping the ratio (16:9) of the iframe.
Working JSfiddle (try resizing the display tab :)).
Html:
<section>
<article id="iframe">
<iframe src="src.html"></iframe>
</article>
</section>
Css:
section{
max-width: 800px;
}
#iframe{
width: 100%;
max-width: 800px;
position: relative;
padding-top: 56.25%;
}
iframe{
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
margin: auto;
display: block;
position: absolute;
}
src: smashingmagazine.com
edit: here's a video of a resizeable iframe :)
edit2: oopps, forgot a section tag
I'm trying to embed a Youtube video into a webpage using Bootstrap, but I want it to take up the whole width of the page.
HTML:
<iframe class="embed-responsive-item youtube" src="https://www.youtube.com/embed/zpOULjyy-n8?rel=0"></iframe>
CSS:
.youtube {
width:100%;
}
JSFiddle
But I have two issues:
The video preview is cutoff by the height when the webpage is large (you can only see half of the video preview).
When the video plays, it is still in its small format.
How can I fix this using Bootstrap?
In Bootstrap v3 this construct will do a full width iframe:
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="https://www.youtube-nocookie.com/embed/H_CN8W_uCys?wmode=transparent&rel=0&showinfo=0" allowfullscreen=""></iframe>
</div>
I know this looks stupid but I was inspired by inspected code on Bootstrap official web page:
.embed-responsive{
position: relative;
padding-top: 56.25%;
}
.youtube{
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
border: 0;
}
56.25% - this is the proportion thing, ya know, 16:9 etc ;)
This is actually solvable with pure CSS through an understanding of aspect ratios. The code is easy enough, just replace your .youtube selector with the following code:
.embed-responsive {
position: relative;
width:100%;
height: 0;
padding-top: 56.25%;
}
.youtube{
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
This sets the parent of the YouTube iframe to have a 100% width fluidly, with an aspect ratio of 16/9, by using a 0 height with a padding top of 56.25%. Then you just need to make the iframe fill that parent, which is achieved with absolute positioning and a height and width of 100%.
You need to add the class container-fluid instead of container.
Try this code:
<section id="about" class="home-section text-center">
<div class="container-fluid">
<div class="row">
<div class="embed-responsive embed-responsive-1by1">
<iframe class="embed-responsive-item youtube" src="https://www.youtube.com/embed/zpOULjyy-n8?rel=0">
</iframe>
</div>
</div>
</div>
</section>
This works great, until I have 2 or more iframes in the same container, then they just overlap each other because they both have the same absolute position.
How do I allow for an arbitrary number of iframes inside of a container built to house iframes and maintain their aspect ratios?
From: https://www.h3xed.com/web-development/how-to-make-a-responsive-100-width-youtube-iframe-embed
The key to creating a responsive YouTube embed is with padding and a container element, which allows you to give it a fixed aspect ratio. You can also use this technique with most other iframe-based embeds, such as slideshows.
Here is what a typical YouTube embed code looks like, with fixed width and height:
<iframe width="560" height="315" src="//www.youtube.com/embed/yCOY82UdFrw"
frameborder="0" allowfullscreen></iframe>
It would be nice if we could just give it a 100% width, but it won't work as the height remains fixed. What you need to do is wrap it in a container like so (note the class names and removal of the width and height):
<div class="container">
<iframe src="//www.youtube.com/embed/yCOY82UdFrw"
frameborder="0" allowfullscreen class="video"></iframe>
</div>
And use the following CSS:
.container {
position: relative;
width: 100%;
height: 0;
padding-bottom: 56.25%;
}
.video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
Don't put 2 videos in the same container. Put 2 containers and wrap them in a single wrapper. Then change the width and bottom-padding to whatever you want.
.container {
position: relative;
width: 50%;
height: 0;
padding-bottom: 28.13%;
display:inline-block;
margin:0;
}
.video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
<div class="wrapper">
<div class="container">
<iframe src="//www.youtube.com/embed/3Sdes6QuPro" frameborder="0" class="video"></iframe>
</div><div class="container">
<iframe src="//www.youtube.com/embed/yCOY82UdFrw" frameborder="0" class="video"></iframe>
</div>
</div>
I'm currently working on website for a video producer. He would like to have his demo reel running in the background when you go to his webpage. I'm trying to create a few div elements that will that will be over the video. They will actually right at the top of the webpage, acting sort of like a navbar, but not really.
Here is the code I'm working with. Of course, you won't be able to see the content when it is run, but maybe I have a mistake some where.
.background-wrap {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
top: 0;
left: 0;
background: #353030;
}
#video-background {
position: relative;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
width: 500;
height: 500;
z-index: 100;
}
#header-container {
position: relative;
display: inline;
z-index: 200;
}
.header-item {
color: white;
letter-spacing: 3px;
text-align: center;
position: absolute;
<div class="background-wrap">
<video width="1700" height="956" autoplay muted loop id="video-background">
<source src="img/reel.mp4" type="video/mp4">
<source src="img/reel.webm" type="video/webm">
<source src="img/reel.ogv" type="video/ogg">
Sorry, your browser doesn't support HTML5 video.
</video>
<div class="row" id="header-container">
<div class="col-md-4">
<div class="header-item">
<h1 id="title">Josh Kelley</h1>
</div>
</div>
<div class="col-md-4">
<div class="header-item">
<h3 id="subtitle" href="https://vimeo.com/204080098" target="_blank">Video Production & Photography</h3>
</div>
</div>
<div class="col-md-4">
<div class="header-item">
<a id="subtitlebutton1" href="#about" class="btn btn-dark btn-lg">About Me</a>
</div>
</div>
</div>
</div>
My biggest problem is when I change my .header-item to position:absolute.
When I inspect the element with developer tools the content is smashed below the video above. You can even see the About Me button is halfway showing.
Here is what it looks like when #header-container changed to position:relative and delete the position css property off .header-item.
I've marked in RED where I want the elements to go. Any help would be amazing.
Sorry I haven't enough time to provide you with complete solution, but:
.background-wrap {
position: relative;
width: 100%;
height: 100%; /*this has effect of 0px in your case*/
overflow: hidden; /*this hides everything that doesn't fit to the container size*/
top: 0;
left: 0;
background: #353030;
}
Here you specified height: 100% but 100% of what? Its a top level element and you set it's child's position to absolute. So the computed height is 0. It would be ok in other cases, but you've set the overflow to hidden...
As I understand, this is why you see nothing when you set the position to absolute.
You should fix all of your sizes keeping in mind that they don't grow to their children's sizes if those children are absolute positioned. After that check your bootstrap's default configurations (is it static by default, is it inline or block and so on).
embedding video in grid system of Bootstrap 3.1, video is not expanding full width of the grid column. How to make it 100% wide to the parent column keeping the aspect ratio?
Also, even if I use a 4:3 video, it appears very wide in the browser with very short height.
here is my code:
<div class="row">
<div class="col-md-8">
.
<!-- other items-->
.
</div>
<div class="col-md-4">
<div class="embed-responsive embed-responsive-4by3">
<iframe class="embed-responsive-item" src="//www.youtube.com/embed/gYhi3pAiQY4"></iframe>
</div>
</div>
</div>
As Rob said in a comment:
Pretty sure embed-responsive wasn't added until 3.2. Try updating.
If you're unable to update, for one reason or another, you can add the styles yourself. It's fairly straight forward. Here's the SASS:
// Embeds responsive
//
// Credit: Nicolas Gallagher and SUIT CSS.
.embed-responsive {
position: relative;
display: block;
height: 0;
padding: 0;
overflow: hidden;
.embed-responsive-item,
iframe,
embed,
object,
video {
position: absolute;
top: 0;
left: 0;
bottom: 0;
height: 100%;
width: 100%;
border: 0;
}
}
// Modifier class for 16:9 aspect ratio
.embed-responsive-16by9 {
padding-bottom: 56.25%;
}
// Modifier class for 4:3 aspect ratio
.embed-responsive-4by3 {
padding-bottom: 75%;
}