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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Why Tailwind CSS Can Be Used Instead of Bootstrap CSS
  • Choosing the Best CSS Frameworks for Enterprise Web Applications
  • How To Integrate a Web Component Into a Mobile App While Preserving Native UX
  • Difference Between Bootstrap and AngularJS in 2022

Trending

  • PostgreSQL vs Oracle: When Higher Cost Means Better Performance
  • Going All In On the JVM 25 Virtual Threads
  • Who Should Grade Your AI? Rules vs LLM Judges vs Humans
  • Replay, Scheduling, and Throttling: Engineering a Self-Service Kafka Streaming Tool at Scale

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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.

By 
Joy Twain
·
Updated Nov. 12, 18 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
110.8K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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.

Related

  • Why Tailwind CSS Can Be Used Instead of Bootstrap CSS
  • Choosing the Best CSS Frameworks for Enterprise Web Applications
  • How To Integrate a Web Component Into a Mobile App While Preserving Native UX
  • Difference Between Bootstrap and AngularJS in 2022

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook