Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
Can't make an MP4 movie height to change and fit in Material Box both landscape and portait

I learn JavaScript React and now I have problem with positioning of an MP4 movie.
I have a Codesandbox

Check the file FileContentRenderer.jsx where the html5-video is used with MP4.

I want it to fit the material Box in portrait with let's say height: '20vw and landscape but whatever I try I can't get it to change I must have missed some fundamental please advice

Like this, here the movie should be just a 4th of the height and not this mega high. Whatever I try this height can't be reduced please advice?

I have this Material withStyles that is not working making the MP4 look good

const styles = theme => ({
    viewerWrapperMp4: {
        background: 'black',
        width: '100%',
        height: '20vw',
        textAlign: 'center',
    },
    viewerMp4: {
        width: 'auto',
        height: '100%',
    },
    outer: {
        height: '100%',
        width: '100%',
        position: 'relative',
        overflow: 'hidden',
    },
});

It does not matter what movie I try the movie refuses to fit the Box

enter image description here

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I've changed your code to this and in the final result, you should change video element CSS to this:

  maxHeight: "20vw";
about 4 years ago · Juan Pablo Isaza Report

0

I believe this piece of code is what you're looking for. It keeps the height and aspect ratio. It makes a video centered. and the width of video is variable.

.video-container {
background: black;
width: 100%;
height: 20vw;
text-align: center;
}

.video {
width: auto;
height: 100%;
}
<div class="video-container">
 <video class="video" controls>
  <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
</video> 
<div>

Obviously, you can't keep both width and height fixed while your videos has different aspect ratios. One of them must be variable. This code keeps height fixed.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!