L
L
LastGeneral2020-05-13 14:21:29
css
LastGeneral, 2020-05-13 14:21:29

How to make a responsive video on a website?

The main screen is divided into 2 parts (in the ratio of 30% - text, 70% - video):

<main class="hero">
  <div class="hero_title">
    <h1>lorem  lorem  lorem !</h1>
 		<h2>lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem</h2>
  </div>
  <div class="hero_video">
    <div class="video">
      <video class="video" loop="" autoplay="" muted="" playsinline="" poster="video.jpg">
          <source src="video.mp4" type="video/mp4">
          <source src="video.ogv" type="video/ogv">
          <source src="video.webm" type="video/webm">
        </video>
      </div>
    </div>
  </main>


main {
    display: grid;
    grid-template-columns: 30% 70%;
}


How to make a video stretch like a picture with the cover property)? And not like this:

5ebbd80b0c71a422813769.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
drawnofmymind, 2020-05-13
@LastGeneral

I wonder if object-fit: cover will work?
like so
video{
width:100%;
height: 100%;
object-fit:cover;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question