Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda