I have used bootstrap to have responsive video , but problem is I have only 2 sizes
class="embed-responsive embed-responsive-16by9"
and
class="embed-responsive embed-responsive-4by3"
these are really huge. how can i change width and height manually , if i try with this
style="width:400px ; height:400px"
the video is re sized but the responsive does not work. please help me .
this is my code
<div align="center" class="embed-responsive embed-responsive-16by9" style="width:400px;height:400px">
<video class="embed-responsive-item" controls>
<source src="<?php echo str_replace("../../../../","",$subvalue->video);?>" type="video/mp4">
</video>
</div>
i need like this
but after adding style width and height i get like this
Aspect ratios can be customized with modifier classes. By default the following ratio classes are provided: 1x1. 4x3. 16x9.
In order for a video to be responsive, the video should always expand to fill the width of its container while maintaining its original aspect ratio. We want to avoid static sizing that can break page layouts, distort the image, or display black bars around the video.
The Responsive Embed classes only set the aspect-ratio (use .embed-responsive-16by9
for a 16x9 video and .embed-responsive-4by3
for a 4x3 one). They'll take up 100% of the width of their containing block.
In order to give them a width, you'll only need to add a container, for example .sizer
, that has a width
set.
.sizer {
width: 300px;
}
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="sizer">
<div class="embed-responsive embed-responsive-16by9">
<video src="http://techslides.com/demos/sample-videos/small.mp4" autoplay controls></video>
</div>
</div>
Another option is to add it inside a Bootstrap grid like this
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="embed-responsive embed-responsive-16by9">
<video src="http://techslides.com/demos/sample-videos/small.mp4" autoplay controls></video>
</div>
</div>
</div>
</div>
Never try to add the width
and height
properties directly to the element with the class .embed-responsive
as that will break its responsiveness. It is not needed to add .embed-responsive-item
unless you want an item different from iframe
, embed
, object
or video
.
Go grab fitvids js and as long as you start with width and height dimensions fitvids will make that video responsive: http://fitvidsjs.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With