Adjust HTML5 video to fit a fixed height dimension

Why is the video not displaying at full width when I set a fixed height?

I am not concerned with preserving the original aspect ratio.

This is the code I currently have:

<video width="100%" height="314" autoplay loop>
    <source src="https://s3-us-west-1.amazonaws.com/lapka-assets/web_blur.mp4" type="video/mp4">
</video>

Here is a JSFiddle for reference:

Any advice on how to make the video display properly?

Answer №1

Almost there! Just tweak the height: auto or remove it entirely. For setting a width limit, utilize max-width and min-width. It's suggested to set the minimum width no lower than 320px to accommodate smaller screens.

UPDATE Upon collaborating with OP regarding the question details, we have concluded that in order to maintain a fixed height for HTML5 Video Stretch, use the following wrapping code:

<div style="overflow: hidden; width: 100%; height: 314px;">
  <video height="auto" width="100%" autoplay loop>
    <source src="https://s3-us-west-1.amazonaws.com/lapka-assets/web_blur.mp4" type="video/mp4">
  </video>
</div>

Ensure that overflow: hidden, width: 100%, and height: 314px attributes are retained for the inner video element.

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

Showing list data from script to template in vue - A step-by-step guide

My task involves displaying data from the main table in MySQL. I need to show the type of each major by comparing it with the id in the faculty table. I have successfully logged this information using console.log, but I'm unsure how to display it on t ...

Implementing useReducer in React for dynamic pagination changes

I'm currently working on a movie project and I am looking to implement pagination within the MoviesFromGenre component. Initially, the MoviesFromGenre component is rendered based on the id obtained from GenresList. I am eager to incorporate Pagination ...

What's the deal with HTTP Request methods and AJAX?

I'm currently developing a function that streamlines the process of sending XMLHttpRequests. This function is structured as follows: XHR(url, method, data); For example, if we call: XHR('Hey.xml', 'get', { hi: 'hey' } ...

Incorporate an icon into an Angular Material input field

I want to enhance my input search bar by adding a search icon from Angular Material : <aside class="main-sidebar"> <section class="sidebar control-sidebar-dark" id="leftMenu"> <div> <md-tabs md-center-tabs id=" ...

Implement a getter function within a specific Firestore section using Vuefire

I am currently seeking a solution to set a property from getters to the firestore section using vue. I have implemented vuefire, but encountered the following error: vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read property 'getToUid' of und ...

What is the method in Mongoose for combining outcomes from two distinct sorts while ensuring a specific total count of results?

In my collection of Jar, each document contains a combination of red and blue marbles. If I aim to retrieve the top 5 Jars based on having a high number of red marbles, I would execute something similar to this: Jar.find({}).sort({red: "desc"}).l ...

Kendo UI Web - MultiSelect: choosing an option multiple times

Currently, I am encountering an issue with the Kendo UI MultiSelect widget when trying to select an option multiple times. An example of this is shown in the image below where I want to choose Schindler's List again after selecting The Dark Knight. Ho ...

tap the hyperlink to complete the form and mimic the action of a designated

I'm working on an HTML form that includes a table and two submit buttons. <input type="image" name="button1" value="First Button" src="some_image.png"> <input type="image" name="button2" value="Second Button" src="some_image.png"> One ch ...

Incorporate a progress bar into the Material-UI table design

I have the following example of a Material-UI table: import React from "react"; import clsx from "clsx"; import { createStyles, lighten, makeStyles, Theme } from "@material-ui/core/styles"; import Table from "@mat ...

Utilizing Three.js to showcase large 3D images from a JSON file

I am in need of showcasing 3D images. I have a .obj file that is 80 MB in size which I converted to a json file size of nearly 75 MB. While using three js, I managed to display a rotating 3D image, but the main issue is the loading speed, which currently t ...

Is it possible to verify an email address using a "Stealthy Form"?

I am exploring the use of HTML5's type="email" validation to develop a function for validating email addresses. My goal is to create a form and add an input that has its type set as email. By attempting to submit the form, I aim to determine whether ...

ClickAwayListener's callback function stops executing midway

I am currently utilizing Material-UI's ClickAwayListener in conjunction with react-router for my application. The issue I have come across involves the callback function of the ClickAwayListener being interrupted midway to allow a useEffect to run, on ...

VueSax notifications are showing up in the wrong place

Could it be my fault or is it due to the alpha status of vuesax that the notifications I want to use are displaying incorrectly? Here is the code extracted from the documentation: openNotification (title_, text_) { //This code is placed inside Vue methods ...

The power of Jquery in conjunction with the .parent() method

Can you explain why the first statement in the given code snippet works while the second one does not? jQuery $('.selector').change(function () { // This code block works $(this).parent(".controls").after( "<div class=\"control-grou ...

Is it possible to execute node.js code within a Java script environment?

I have a javascript code that functions as a discord bot. Typically, to run this bot, I would open the command prompt in the js path and enter node {file_name}.js. Now, let's say I have another javascript code that I want to execute on button click an ...

Is it possible to launch a browser window using javascript?

I need to open a new Internet Explorer browser window and I am currently using the following code: window.open("http://jsc.simfatic-solutions.com", "mywindow"); However, I would like to know how can I open a new IE window with a fresh session? ...

Looking to leverage iframes in your Javascript code?

Currently, I am implementing a JSP popup window using JavaScript with an iframe to display a table of multiple records. However, when I disable the table of multiple records, it does not prevent the onclick function (hyperlink). The code snippet is provid ...

Character count in textarea does not work properly when the page is first loaded

As English is not my first language, I apologize in advance for any grammar mistakes. I have implemented a JavaScript function to count the characters in a textarea. The code works perfectly - it displays the character limit reducing as you type. However, ...

Can the submit ID value be utilized in PHP?

name="submit" functions as expected. if(isset($_POST["submit"])) <input type="submit" ID="asdf" name="submit" value="Save" class="ui blue mini button"> I want to change it to use ...

"What exactly does {...props} refer to and what is the best way to obtain my function from another

Currently, I am focusing on learning react native with a specific interest in react navigation v5. As mentioned in this resource: https://reactnavigation.org/docs/themes/#using-the-current-theme-in-your-own-components, my goal is to implement a dark mode ...