I have a website using bootstrap and on the core of my page I have a picture and below is a youtube video embeded:
<div class="col-xs-12 col-sm-12">
<a href="tech.php">
<img class="img-responsive img-rounded" src="assets/tech_withText.jpg" alt="Generic placeholder image" width="1200" height="600">
</a>
<br>
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/RTwv1Dn2rYQ" width="300" height="150" frameborder="0" autoplay=1 allowfullscreen></iframe>
</div>
</div>
Link to website here.
When I first load this page what I see with this solution (and dislike) is that my video extends below my screen. So I am after a way to state the size of my picture and video as a ratio of the screen size, so that my video resizes to stay within the boundaries of the screen.
I have looked for ideas on the internet (i.e. css edit as in here) but I get lost or it does not do what I expect.
Any idea?
If you just add a CSS entry to specify the minimum height of the video it will not clip it on load and bootstrap will take care of keeping it in ratio on resize. Code:
.embed-responsive{
min-height:100%;
}
Of course you will probably want to target the div a little more specifically but I think this should do what you are after.
I would go about this differently, I wouldn't use an absolute positioned element for video and I would set a height or min-height to use viewport units vh
So it might look like:
#youtube-video {
width: 100%;
min-height: 40vh;
}
And remove all the absolute positioning on that element.
Additionally you might want to set an ID or class on your top container and give it some margin-top to offset your fixed header:
#top-container {
margin-top: 50px;
}
Lastly I would move the footer outside the bootstrap container completely by moving the </div> to be above your footer.
<div class="container">
....
</div>
<footer class="footer">
...
</footer>
Related
There are similar questions but I couldn't find an answer to my specific need for the container to be always wrapping around the video without leaving empty spaces (letterboxing), video not to overflow and video aspect ratio not to change. I tried everything, either the horizontal video works or the vertical video works, but never both.
Simple sample code to get the idea across:
<div class="parent" style="max-height: 150px; max-width: 100px;" >
<!-- Mock horizontal video -->
<video class="video" width="400" height="200"></video>
</div>
<div class="parent" style="max-height: 150px; max-width: 100px;">
<!-- Mock vertical video -->
<video width="200" height="400"></video>
</div>
I would like any video input to fit the parent container without overflowing and stretching, while the parent container wraps around the video wherever there is empty space not filled with video.
The end result from this should look like this:
note: wrong height on the second shape. Should have been 150px. Unable to reupload the fixed version.
Here's a JSFiddle link with the clean mock: https://jsfiddle.net/wfhv389j/63/
I want the video iframes to use the full container width.
To illustrate, I have a Bootstrap v5.2.2 container with a single row using justify-content-center and a single column using col-auto:
<div class="container">
<div class="row justify-content-center">
<div class="col col-auto">
...
</div>
</div>
</div>
This centers paragraphs within the column div if none of them fill the full width of the container, while keeping paragraphs left-justified.
That works great, except when I embed YouTube videos as iframes in the column div.
The iframes are only as wide as the widest content in the column div. If the longest content other than an iframe is the word "the", the iframe is literally that wide; it's unusable. If the iframe is the only item, then it's not displayed at all.
Here's an example of a YouTube iframe:
<iframe src="https://www.youtube.com/embed/zpOULjyy-n8" allowfullscreen></iframe>
If I use the Bootstrap "embed-responsive" and "embed-responsive-item" classes like this:
<div class="embed-responsive">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/zpOULjyy-n8" allowfullscreen></iframe>
</div>
Then the iframe is displayed, but it's a constant 300px width, even if the container or other content is much wider, which looks tiny and is difficult to use on desktop displays.
I can't figure out how to have text centered in the container by col-auto, but have YouTube iframes expand to always fill the container width.
having an issue, it's early in the morning so it's probably very simple! basically this is my code:
<div class="form-group">
<label>Preview</label>
<div style="border:1px solid black; height:2px!important;"class="embed-responsive embed-responsive-4by3">
<iframe class="embed-responsive-item" src="//player.vimeo.com/video/{{$video->link}}"></iframe>
</div>
</div>
For some reason I cannot set the height of the video div. Currently the problem is that the iframe is sized correctly, but the containing div has an unnecessary height which is pushing the form submit button down out of the user's view. I would like to be able to adjust the height of the div
For some reason my iframe height is constrained, whether I set it in CSS or in the tag. I'm not sure what this is all about and searches reveal nothing. I'm not sure what to do at this point and may need to abandoned the embeds. Also, when I force the container to 960px (the height of the video) it will get a scroll bar with no overflow options defined. Weird.
http://jordan.rave5.com/tmpstuff/
<div class="left-large-box">
<div class="large-box">
<div class="large-box-content">
<div class="content-full">
<div class="column-header">
<div class="column-icon">
Title here
</div>
</div>
<p><iframe width="690" height="388" src="http://www.youtube.com/embed/jH7f6e9FsLc" frameborder="0" allowfullscreen></iframe></p>
</div>
</div>
<div class="box-end"></div>
</div>
</div>
In your style sheet blue.css you apply height: auto; to all elements, that overrides the height attribute of the iframe. You can still use a style on the element to set the height though.
If you remove the height: auto, the height attribute works also.
On this page an embedded YouTube video is displayed to the left of a carousel titled "Similar Festivals". The HTML used to embed the YouTube video is:
The HTML of the YouTube section is:
<div class="span4 spacer youtube">
<div class="title clearfix">
<h2 class="pull-left">YouTube</h2>
</div>
<iframe width="1000" height="1000" src="http://www.youtube.com/embed/NI8rQEHoE24"></iframe>
</div>
The layout of the page (using a responsive Bootstrap grid) is such that the video should have the same height as the carousel to the right of it, but as you can see, it is somehow breaking out of its parent container. I want the video to be aligned with the carousel to its right, how can I fix this.
Here's a screenshot in case there's any doubt about what I'm referring to!
I've noticed that row-fluid container is dynamically adding a width of 33% to your Youtube video. So whatever width expectation you set to it is being reset by that class.
Try this:
<div class="row-fluid">
<div class="span4 spacer twitter">
</div>
<!-- Youtube -->
<div class="span4 spacer youtube">
<div class="title clearfix">
<h2 class="pull-left">YouTube</h2>
</div>
<iframe height="150px" src="http://www.youtube.com/embed/NI8rQEHoE24"></iframe>
</div>
<!-- Similar Carousel -->
<div class="span4 spacer">
<div id="similarCarousel" class="carousel slide last">
</div>
</div>
</div>
(hat tip to Mr. Alien)
It sets the iframe height only. The whole row-fluid container expands somewhat, and the height is irregular. However, you don't have the 'jumping outta the container' problem.
Instead of
<iframe id="fitvid811516"
src="Festivals.ie%20_%20Electric%20Picnic%202012_files/NI8rQEHoE24.htm">
</iframe>
Use this
<iframe width="640" height="360"
src="http://www.youtube.com/embed/NI8rQEHoE24?feature=player_detailpage"
frameborder="0" allowfullscreen>
</iframe>
And adjust width and height manually. Iframes don't go along well with dynamic sizing.
Also if you don't want to break the layout but also don't want to change the content within, you can also go to the parent container in HTML and set overflow: hidden
.fluid-width-video-wrapper {
overflow:hidden;
}
Note that this would fix your layout but break the iframe; its bottom parts where play controls stay would be hidden.