DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Frameworks
  4. How to Implement Bootstrap Responsive Video

How to Implement Bootstrap Responsive Video

If you're new to web development, check out this article on how utilize Bootstrap to create responsive videos on your web page.

Joy Twain user avatar by
Joy Twain
·
Nov. 12, 18 · Tutorial
Like (11)
Save
Tweet
Share
105.42K Views

Join the DZone community and get the full member experience.

Join For Free

If you are using any videos on your website then make sure they are responsive in nature. A responsive videoautomatically adapts to the screen size of the user.

In this tutorial, you will learn how to implement Bootstrap Responsive Video in your website.

How to Put Videos on a Website

Mostly we use the HTML 5 Video Tag to put a video on a website. The video tag is shown below:

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
</video>

However, we can also embed videos from third-party websites like Youtube and Vimeo.

In Youtube, click the “Share” button then click the “embed” button to copy the embed code of the video. Now, to show this video on your website, simply paste this embed code into your web page, and that’s all. This video will now show up on the web page.

In the below picture, I have marked how to copy the Video’s embed code from Youtube.

how to get embed video code in youtube

Bootstrap Responsive Code

In Bootstrap, the video should be placed in one of two ways – an aspect ratio of 16:9 or 4:3. The code for this is given below:

<!-- 16:9 aspect ratio --> 
<div class="embed-responsive embed-responsive-16by9"> 
    //add video code 
</div> 

<!-- 4:3 aspect ratio --> 
<div class="embed-responsive embed-responsive-4by3">
    //add video code
</div>

Note: There is a prerequisite that you should know how to use Bootstrap on your website. So that you can create a Bootstrap grid and place the video in that grid.

If you want to place a video tag then the above code will become:

<!-- 16:9 aspect ratio --> 
<div class="embed-responsive embed-responsive-16by9"> 
    <video width="320" height="240" controls>
        <source src="movie.mp4" type="video/mp4">
    </video>
</div> 

<!-- 4:3 aspect ratio --> 
<div class="embed-responsive embed-responsive-4by3">
    <video width="320" height="240" controls>
        <source src="movie.mp4" type="video/mp4">
    </video>
</div>

In the same way, if you are using a Youtube embed code for a video then the Bootstrap Responsive Video code will become:

<!-- 16:9 aspect ratio --> 
<div class="embed-responsive embed-responsive-16by9"> 
    <iframe width="560" height="315" src="https://www.youtube.com/embed/VS6UOyTb5eU" 
frameborder="0" allowfullscreen></iframe>
</div> 

<!-- 4:3 aspect ratio --> 
<div class="embed-responsive embed-responsive-4by3">
    <iframe width="560" height="315" src="https://www.youtube.com/embed/VS6UOyTb5eU" 
frameborder="0" allowfullscreen></iframe>
</div>

Testing Bootstrap Responsive Video

Let me show you how this responsive video will look in different screen sizes. I have given 3 screenshots of the view given by these responsive videos.

a. Responsive Video in Smartphones

responsive video in smarphones



b. Responsive Video in Tablets

responsive video in tablets

c. Responsive Video in Laptops

responsive video in laptops

You can check out a demo, here. 

Conclusion

Isn't Boostrap really easy to use? If you have any questions/comments on Bootstrap or this tutorial, then make sure to provide it in the below comments section.

Bootstrap (front-end framework)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Kubernetes vs Docker: Differences Explained
  • OpenID Connect Flows
  • Key Considerations When Implementing Virtual Kubernetes Clusters
  • Distributed SQL: An Alternative to Database Sharding

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: