Embed a video onto a webpage using HTML and ensure it is responsive by implementing Bootstrap's grid

I am currently using the mPurpose-master bootstrap theme, which offers a feature allowing the placement of 3 blocks in a row that are fully responsive.

<div class="section">
    <div class="container">
        <div class="row">
            <div class="col-md-4 col-sm-6">
                DATA ONE
            </div>
            <div class="col-md-4 col-sm-6">
                DATA TWO
            </div>
            <div class="col-md-4 col-sm-6">
                DATA THREE
            </div>
        </div>
    </div>
</div>

I would like to make modifications to this layout by placing a video in the center of the screen/row while maintaining responsiveness. I attempted the following code, leaving the first and third div empty and placing the video in the second div:

<div class="section">
    <div class="container">
        <div class="row">
            <div class="col-md-4 col-sm-6">

            </div>
            <div class="col-md-4 col-sm-6">
                <video controls autoplay height="340" width="267">
                    <source src="<? echo $video_link;?>" type="video/mp4">
                </video>
            </div>
            <div class="col-md-4 col-sm-6">

            </div>
        </div>
    </div>
</div>

The above code works well, but if the dimensions of the video are adjusted, it loses its responsiveness.

Another approach I tried is as follows:

<div class="container">
    <div class="row">
        <div class="col-md-6">
            <video controls autoplay>
                <source src="<? echo $video_link;?>" type="video/mp4">
            </video>
        </div>
    </div>
</div>

This method positions the video to the left and does not maintain responsiveness.

Currently, the video size is too small. I have three main objectives:
1) Increase the video size to 640*360.
2) Center the video on the screen.
3) Ensure responsiveness.

Answer №1

If you want the video to be the main focus in this row, columns may not be necessary. By applying the CSS below, you can center and make the video responsive:

#video-containing-div video {
    display: block;
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;
}

Manually setting the width and height in your HTML will remove the video's ability to adjust responsively. Additionally, attempting to increase the video size with styling may result in a loss of picture quality. For better resolution, consider shooting the video in higher quality.

Answer №2

Why not simply create a centered div for your video without relying on bootstrap columns? Try implementing this structure in your HTML:

<div class="row">
    <div class="video-container">
        Insert your video content here
    </div>
</div>

Next, adjust your CSS with the following styles:

.video-container {
    margin-left:auto;
    margin-right:auto;
    max-width: 640px; /* Define max width of the video as 640px */
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for setting a default value in a Reactive Form

How can I transfer a default value from HTML to TypeScript using reactive forms? <ul class="list list_2"> <li>Subtotal <span>{{cartTotal | currency:'INR':true:'2.0'}}</span></li> <li>Shippin ...

Error importing reach-router in Gatsbyjs causing website to break

While working on my Gatsby project, I decided to incorporate the React Cookie Consent package. However, upon installation and implementation attempt, my website crashed, displaying this error message: warn ./.cache/root.js Attempted import error: &a ...

Switching the vertical alignment of grid items in Material UI when the page is collapsed

When the page is collapsed, the Left grid item element moves to the top of the page and the Right grid element is positioned below it. I would like to reverse this behavior so that the Right element appears on top and the Left element below when the page ...

Is there a way to troubleshoot the issue pertaining to using routerLink in Angular version 17.2?

Currently working on a small app, but encountering an error with routerLink in the console. I am new to angular and seeking help. ✘ [ERROR] NG8002: Can't bind to 'routerLink' since it isn't a known property of 'a'. Here is ...

Is there a way to align this in a horizontal inline block?

I have this element and I would like it to display inline-block but horizontally. Currently, it is displaying as inline-block but vertically. Here is my HTML: <div class="ondisplay"> <div class="left-text"> <p&g ...

Centering text both vertically and horizontally over an image using CSS

I've been attempting to center the div banner_title both vertically and horizontally within another div in this way... .box { text-align: center; } .banner_title { font-size: 32px; position: absolute; top: 50%; width: 100%; } .banner_titl ...

Check to see if the date selected from the HTML5 date picker is in the past compared to the current date

When working with HTML, I have a task where I need to input a date (mm/dd/yyyy) using the new HTML 5 date picker: <input name="date" type="date"> My goal is to validate whether the date entered is older than today's date. $this_date = $_POST ...

The animation in my SVG comes to a halt at a certain point

I am having an issue with my SVG element (shown below) where it stops animating after a certain period of time. I want the animation to continue indefinitely like in this jsfiddle. .path { stroke-dasharray: 20; animation: dash 10s linear; } @ ...

Interactive Image Effects with Hover using HTML and JavaScript

I have observed that the transform works fine, but there is a slight issue when initially hovering or touching the image. After the first touch or hover, everything works great. Any assistance on fixing this minor issue would be greatly appreciated. Thank ...

Adding a stylesheet dynamically to the <head> tag using $routeProvider in AngularJS

Is there a way to load a specific CSS file only when a user visits the contact.html view on my AngularJS application or site? I came across this helpful answer that almost made sense to me How to include view/partial specific styling in AngularJS. The acce ...

Using JavaScript or JQuery, move an image from one location to another by removing it and adding

Firstly, feel free to check out the JSFiddle example My task involves moving an image with the class "Full" after a div with the class "group-of-buttons" using JavaScript. Here is the snippet of HTML code: <img src="http://i.telegraph.co.uk/multimedia ...

Is there a way to efficiently integrate text from a webpage into a "Twitter Share" button automatically?

I have a cool feature on my website - a random quote generator where users can tweet the current quote at the click of a button. I've set up a Twitter share link using jQuery that dynamically updates with each new quote: $('.twitter-share-button ...

A guide on incorporating an event to multiple elements in vue.js

I am trying to implement a double-click event on multiple elements in Vue3. My goal is to create a table of contents data and add a double-click event to the checkboxes and favorite icons without using @dblclick="". I find it more convenient to assign a c ...

Bootstrap4 lacks responsiveness

html, body { background-color: #E3E3E3; width: 100%; height: 100%; margin: 0; padding: 0; } /* Custom Styling */ .section1 { background: url("../images/laptop-table1920-gray.jpg") no-repeat center center fixed; -webkit-background-size: cover ...

Using the onreadystatechange method is the preferred way to activate a XMLHttpRequest, as I am unable to trigger it using other methods

I have a table in my HTML that contains names, and I want to implement a feature where clicking on a name will trigger an 'Alert' popup with additional details about the person. To achieve this, I am planning to use XMLHttpRequest to send the nam ...

The drop-down menu is malfunctioning as it is not displaying the complete text and the

At the moment, I am facing an issue where my submenu items for Add Subject, Drop Subject, and Delete Subject are not centralized as intended. Additionally, the Executive Summary text in the submenu is getting cut off. Can someone please help me with expand ...

Retrieving data from the database requires a significant amount of time

I'm currently experiencing a delay of around 15 seconds when running this query and I'm looking to optimize it. SELECT *, `points`.`players` as `players` , FROM_UNIXTIME(`points`.`timestamp`, '%Y-%m-%d %H:%i') as `date`, (SELEC ...

"Implementing a function where two different elements can change the text of a button

I have created a custom FAQ script using dl, dt, and dd elements: $('.faqs dd').hide(); // Hide all DDs inside the .faqs container $('.faqs dt').hover(function(){ $(this).addClass('hover' , 'slow')},function(){ ...

Angular provides the capability to sort through data using various criteria

I have received an array of objects in a specific format from the server, which may contain more than 2 objects. [ {processId : 1, processName : "process1", country : "germany", companyCode:"IB" , companyHiringType:"FRE", masterClauses:[ {cl ...

Adjusting page layout following window dimension changes

Every time I work on developing HTML pages, I encounter issues with window resizing. The alignment of the page gets disrupted and elements end up overlapping each other. I want my page to maintain its layout when resized, with scrollbars appearing instea ...