Michael Kibuku
Michael Kibuku

Reputation: 67

Video width fix and Text positioning on video and making text mobile responsive

I have tried positioning the text center which they are aligned center but on the left side. I would love it to be center aligned to the site. Also, the video leaves the page with overflow wherein other videos I have done practice with, have reacted well with the width:100% but this doesn't work. Lastly, I would still like someone to help me with making the whole section mobile responsive. Thanks.

.outer-container {
  width: 100%;
  height: 100%;
}
.inner-container {
  display: inline-block;
  position: relative;
  width: 100%;
}
.video-overlay  {
  position: absolute;
  margin-top: 2rem;
  font-family: 'calibri';
  color: #FFF;
}

.video-overlay h1, h4, h6 {
  font-family: 'calibri';
  color: #fff;
  text-align: center;
}

.video-overlay 

video {
  margin-top: 100px;
  width: 100%;
  height: 100%;
}
<section>
    <div class="outer-container text-center">
      <div class="inner-container">
          <div class="video-overlay">
            <h4>"Its better to travel well than to arrive"</h4>
            <h1>Dream . Travel . Explore</h1>
            <i><h6>"<b>Video by: </b> www.standupfornature.org"</h6></i>
          </div>
          <video id="player" src="https://cdn.videvo.net/videvo_files/video/free/2019-11/small_watermarked/190301_1_25_11_preview.webm"  autoplay muted loop></video>
      </div>
  </div> 
  </section>

Upvotes: 2

Views: 499

Answers (1)

Debsmita Paul
Debsmita Paul

Reputation: 1460

  1. You have an extra .video-overlay in your CSS.
  2. I have removed margin-top: 100px from video (just to be more clear)
  3. I have used translateY property to vertically center the text.
  4. I have made .video-overlay 100% width and center aligned the text content with text-align: center.

.outer-container {
  width: 100%;
  height: 100%;
}
.inner-container {
  display: inline-block;
  position: relative;
  width: 100%;
}
.video-overlay  {
  position: absolute;
  width: 100%;
  text-align: center;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'calibri';
  color: #FFF;
}

.video-overlay h1, h4, h6 {
  font-family: 'calibri';
  color: #fff;
  text-align: center;
}



video {
  width: 100%;
  height: 100%;
}
<section>
    <div class="outer-container text-center">
      <div class="inner-container">
          <div class="video-overlay">
            <h4>"Its better to travel well than to arrive"</h4>
            <h1>Dream . Travel . Explore</h1>
            <i><h6>"<b>Video by: </b> www.standupfornature.org"</h6></i>
          </div>
          <video id="player" src="https://cdn.videvo.net/videvo_files/video/free/2019-11/small_watermarked/190301_1_25_11_preview.webm"  autoplay muted loop></video>
      </div>
  </div> 
  </section>

Upvotes: 3

Related Questions