Implementing a video background within a dynamic two-column layout, accompanied by text within a separate column

While viewing on a large screen with Bootstrap 5, everything looks good:

https://i.sstatic.net/Vm6bH.png

However, when I resize the screen, the text in the first column overflows onto the sections below instead of adjusting properly.

https://i.sstatic.net/4wrMq.png

This was my original code:

<section class="bg-overlay ratio ratio-21x9 bg-soft-blue">
  <video poster="./assets/img/photos/movie2.jpg" src="./assets/media/home.mp4" autoplay loop muted></video>
  <div class="video-content">
    <div class="container">
      <div class="row pt-10">
        <div class="col-lg-6 bg-soft-blue">
          <h2 class="text-uppercase heading mb-5">Title</h2>
          <p class="lead fs-lg lh-sm">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
          <span><a href="#" class="text-uppercase btn btn-outline-primary rounded-pill" data-bs-toggle="modal" data-bs-target="#modal-signup">Read More</a></span>
        </div>
        <div class="col-lg-6"></div>
      </div>
    </div>
  </div>
  <!-- /.video-content -->
</section>

I attempted to modify it like this:

<section>
  <div class="row pt-10 bg-soft-blue">
    <div class="col-lg-6 bg-soft-blue">
      <h2 class="text-uppercase heading mb-5">Title</h2>
      <p class="lead fs-lg lh-sm">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
      <span><a href="#" class="text-uppercase btn btn-outline-primary rounded-pill" data-bs-toggle="modal" data-bs-target="#modal-signup">Button</a></span>
    </div>
    <div class="col-lg-6 bg-overlay ratio ratio-4x3">
      <video poster="./assets/img/photos/movie2.jpg" src="./assets/media/home.mp4" autoplay loop muted></video>
      <div class="video-content">
        <div class="container">
          video here
        </div>
      </div>
    </div>
  </div>
  <!-- /.container -->
</section>

However, this approach actually divides it into two sections and worsens the problem. I also tried embedding a video but it didn't auto-play. It's acceptable if the video doesn't work on small screens and is just an image, but responsiveness is crucial. I suspect it might be a positioning issue in the first column or perhaps it's not achievable. Any assistance would be greatly appreciated.

Answer №1

It appears that the issues you are encountering stem from placing ratio classes directly on the column. For optimal performance with Bootstrap grid elements (.container, .row, .col-*), it is recommended to nest the video container inside the column. The grid works best when used to contain BS components rather than being treated as the component itself.

This code snippet showcases the text stacking above the video on smaller screens and appearing side-by-side on medium-sized screens and larger, thanks to the .col-12.col-md-6 class. Make sure all content elements are fully nested within the .col-* classes:

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ef8d80809b9c9b9d8e9fafdac1ddc1dd">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">

<section>

  <div class="row pt-10 bg-soft-blue">

    <div class="col-12 col-md-6 bg-soft-blue">
      <h2 class="text-uppercase heading mb-5">Title</h2>
      <p class="lead fs-lg lh-sm">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
        dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
      </p>
      <span><a href="#" class="text-uppercase btn btn-outline-primary rounded-pill" data-bs-toggle="modal" data-bs-target="#modal-signup">Button</a></span>
    </div>
    <div class="col-12 col-md-6">

      <div class="bg-overlay ratio ratio-4x3">
        <video poster="https://dummyimage.com/400x300/a00/cf.png&text=4:3" src="./assets/media/home.mp4" autoplay loop muted></video>
        <div class="video-content">
          <div class="container">
            video here
          </div>
        </div>
      </div>
    </div>

  </div>

</section>

<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="93f1fcfce7e0e7e1f2e3d3a6bda1bda1">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>

Answer №2

After much consideration, I believe this solution will do the trick. Sharing in case it can benefit someone else.

<section class="bg-soft-blue">
<div class="row  pt-10">
<div class="col-lg-6">
<h2 class="text-uppercase heading mb-5">Title</h2>
<p class="lead fs-lg lh-sm">copy</p>
<span><a href="#" class="text-uppercase btn btn-outline-primary rounded-pill" data-bs-toggle="modal" data-bs-target="#modal-signup">Read More</a></span>
                     
</div>
 <div class="col-lg-6 ">
<div class="bg-overlay ratio ratio-21x9  ">
 <video poster="./assets/img/photos/movie2.jpg" src="./assets/media/home.mp4" autoplay loop muted></video>
<div class="video-content">
</div>
</div>
</div>

</div>
<!-- /.video-content -->
</section>
<!-- /section -->

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

Spacing between products in Woocommerce product list

Welcome to my website! Check it out here: I am facing an issue with a long margin at the bottom of my woocommerce product list. I have tried using CSS to change it as shown below: .woocommerce .products ul, .woocommerce ul.products { margin-bot ...

Identifying the Operating System and Applying the Appropriate Stylesheet

I am trying to detect the Windows operating system and assign a specific stylesheet for Windows only. Below is the code snippet I have been using: $(function() { if (navigator.appVersion.indexOf("Win")!=-1) { $(document ...

Find all elements located in between two headers with varying ids

I am trying to select a specific range of elements in between two headers, excluding everything after the second header. For example, I want to select elements 1-5 from the following code snippet: <!DOCTYPE html> <html> <head> <link r ...

Automatically resizing a multi-part CSS background based on content dimensions

My current CSS project has hit a snag that I can't seem to solve: There is a box on the left side of the site that contains three images - a top image, an optional and stretched middle image, and a bottom image. I want this left box to automatically ...

Issues with Datepicker functionality in Bootstrap 5 are causing it to malfunction or not display

I am having trouble incorporating a timepicker on my webpage with bootstrap 5. The calendar feature isn't loading properly, preventing me from selecting any dates. I'm unsure if the issue lies with an error on my end or if the plugin isn't c ...

Alignment of headers and footers in email newsletters for various email clients<td>

With my limited coding skills, I've been struggling to keep the header and footer aligned properly in all email clients. The footer consistently displays a 1 px gap between elements, which causes it to move around unpredictably. Here's the full s ...

When it comes to handling media queries, iPhone is geared towards min-width dimensions of 768

The layout of my landing page has a CSS structure that looks like this: body { background: white; } @media (min-width: 768px) { body { background: red; } } @media (max-width: 767px) { body { background: blue; } } Des ...

Is there an issue with the padding not functioning correctly on smaller and medium-sized devices when using Bootstrap

On my desktop, I added '50px' padding to the body of my page and it's working properly. However, on smaller and medium screens, it's not functioning correctly. I tried using Bootstrap @media CSS functionality, but it still doesn't ...

Function activation in Element requires a double click to initiate

I've encountered an issue with a web element I'm working on where the click function only triggers after the first click, rendering the initial click ineffective. Here's the code snippet in question: HTML: <div> <a href="#0" cla ...

Is there a way to utilize the reset() function within an input form?

Is there a way to automatically reset the textbox when submitting a value? Below is my code: <!DOCTYPE html> <html> <body> <ul id="myList"> </ul> <input type="text" id="myText" value="&q ...

The hover animation is not functioning properly in Icomoon

I have implemented a menu with a CSS3 hover animation called toTopFromBottom. Now, I want to replace the Font Awesome icons with Icomoon icons and apply the same animation effect: HTML: <div id="top-bar" class="top-bar"> <div class="container" ...

Efficiently shrink column width in Material-UI's <TableRow/> using ReactJS and Material-UI

At the moment, I am utilizing ReactJS along with Material-UI. One issue I am encountering is that when using Material-UI's <Table>, the columns' width are automatically set based on content which results in all columns having equal width. H ...

Modify font color in collapsed state of bootstrap navbar dropdown

I've been attempting to modify the font color displayed in the image to ensure it stands out clearly. https://i.sstatic.net/e6VdG.png This is a simple bootstrap 3 navbar. Here's the HTML code: <nav class="navbar navbar-custom"> ...

The presence of the target tag remains unchanged when a media query is used

Hello, I have a question regarding a specific issue in my code. I am trying to use a media query to make a tag disappear when the width of the window is less than 1200px, but it's not working as expected. I believe it might be related to inheritance. ...

Tips for centering the search popup in jqgrid

Having trouble centering the Search popup in my jqgrid. Every time I click on the search button in jqgrid, the Search popup appears at the beginning of the grid. $(document).ready(function(){ //jqGrid $("#usersList").jqGrid({ ...

Several buttons converging towards a single circle

https://i.sstatic.net/NyHXu.png I attempted to create a circular layout using 6 buttons, but the end result did not form a perfect circle as intended. In the image provided, I highlighted the areas of concern in red. Below, you will find my HTML and CSS c ...

CSS-only Tooltip: text is getting truncated

I am experimenting with adding tooltips to my forum posts. Short tooltips work fine, but longer ones are causing issues by cutting off text. Changing the position property from relative to absolute fixes this problem, but causes the text to overlap. Here ...

Exploring the process of constructing this form with the assistance of Bootstrap

Create Dropdown Form https://i.sstatic.net/rqJtS.png I am looking to create a form that allows for updating team scores based on kills. I am struggling to divide the form into 2 sections for input, as demonstrated. I am using only bootstrap for styling, ...

The bottom margin of the last element does not affect the size of its container

I'm curious as to why the margin-bottom of .content-b isn't affecting the height of the .container. .container { background: grey; } .content-a, .content-b { height: 100px; border: 1px solid red; margin-bottom: 100px; } <div class= ...

Connecting images and text from a distance

After days of researching this topic, I have not found any solutions that align exactly with what I am trying to achieve. I believe it should be a simple task using just HTML and CSS, but I seem to be facing some difficulties. Initially, my goal was to ma ...