What is the best way to insert a video as the background of a section in HTML Bootstrap while also reducing its opacity?

`Hello everyone! I'm diving into coding and creating my own website for the first time. I've managed to put together a decent site, but now I want to take it up a notch by adding video backgrounds that adjust automatically based on the device.

Below is the section of code where I need some help:

<section id="about" class="test-gradient-background about-section whiteline">
    <div class="container">
      <div class="row align-items-center">
        <div class="col-md-6">
          <h2>Who are we?</h2>
          <p>Paragraph </p>
          <a href="#contact" class="btn btn-outline-light btn-primary btn-lg">Contact Us</a>
        </div>
        <video id="videobcg" preload="auto" autoplay="true" loop="loop" muted="muted" volume="0">
          <source src="./images/chess.mp4" type="video/mp4">
         </video>
        <div class="col-md-6 text-center">
          <img src="./images/C8N.png" class="img-fluid cropped-ofp" alt="C8N Image">
        </div>
      </div>
    </div>
  </section>

css :


.gradient-background {
  background: linear-gradient(300deg, #00bfff, #ff4c68, #ef8172);
  background-size: 180% 180%;
  animation: gradient-animation 18s ease infinite;
}


.whiteline {
  border-bottom: 2px solid #ccc;
  padding-bottom: 2rem;
}

`I could use some advice on how to seamlessly integrate a video tag with auto-adjusting capabilities. I've spent countless hours trying different methods with no luck. Although I've watched numerous tutorials on YouTube, none seem to work as easily as they depict. If anyone has a solution or alternative lines of code, I'd greatly appreciate it.`

Answer №1

This CSS code is exactly what I've been searching for...

  section {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 100vw;
      height: 100vh;
      background-color: #f2f2f2;
    }

The key to this design lies in using the viewport width and height units, denoted by vw and vh respectively, which provide responsive sizing based on the viewing device's screen dimensions.

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

What is the preferred choice: using camelCase in CSS with Styled Components or Emotion for standard React development?

When I'm coding with React Native, I use the styled properties that follow most of CSS syntax and are formatted in camel case. For instance: //... <Component style={styles.container} /> //... const styles = StyleSheet.Create({ ...

Error: jQuery Datatables Library encounters an issue with undefined variable "oColumn"

I'm encountering an issue with implementing the jQuery Datatables library on my Joomla website's table. The script partially styles the table, but then stops (changing header and text colors, but missing datatables controls). http://datatables.ne ...

Make sure to link the hover effects of .content and img together, allowing them to both activate simultaneously

I'm attempting to synchronize the activation of these two hover classes: #recent-posts .content:hover { -webkit-box-shadow: 0px 0px 10px 3px rgba(0,0,0,0.04); -moz-box-shadow: 0px 0px 10px 3px rgba(0,0,0,0.04); box-shadow: 0px 0px 10px 3p ...

unable to retrieve parent ID

I am having trouble retrieving the ID of the parent's parent of the event target. It keeps coming back as undefined, but I have verified through firebug that the ID does exist. Below is my HTML markup: <div class="grid-stack-item ui-draggable ui- ...

Problem encountered when incorporating PHP code into HTML

I have a PHP forum and an HTML website that I am trying to merge for a cohesive appearance. However, I have encountered an issue when attempting to integrate the PHP code into the HTML file. Despite using the following code: <?php echo "here goes my P ...

Heroku - JavaScript and CSS Updates Causing Loading Issues

Ruby version: 2.1.5 | Rails version: 4.1.1 For some reason, the changes I make to my JavaScript and CSS files are not reflecting on Heroku; it seems like the cached assets are still being used. I've tried removing the assets and precompiling them bef ...

Update the image when the radio button is chosen

I've customized two radio buttons by hiding the input marks and replacing them with images: <div class="card-block center-style"> <div class="form-check inline-style"> <label class="form-check-label question-label"> ...

Dealing with JS and Spring issues

I created a simple script that retrieves longitude and latitude values and populates an input form. Here is the HTML: <p id="demo">Click the button to get your coordinates:</p> <button onclick="getLocation()">Try It</button> <sc ...

What could be the reason for my Bootstrap collapse navigation bar not functioning properly?

<!DOCTYPE html> <html lang="en"> <head> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <!-- Optional theme --> ...

The width of the div element is not functioning properly in my code

<div id="content" style="background-color:#ffffff; width:600px;"> This code snippet creates a div with a white background color that stretches across the entire width of the page. To limit its width to a specific size, you can adjust the width prope ...

Is there a way to collapse just one specific row in Angular?

I am struggling to toggle only the selected row, any suggestions? Take a look at my code and demonstration here: https://stackblitz.com/edit/test-trainin-2-gv9glh?file=src%2Fapp%2Fapp.component.scss Currently, all rows are being toggled when clicked, but ...

A step-by-step guide on customizing the background color of a Dialog in Angular Material (Version 16)

I've been attempting to modify the background color of my Angular Material Dialog by utilizing the panelClass property in the MatDialogConfig. Unfortunately, I'm encountering a partial success. I am aiming to set the background color as red (jus ...

Images that adapt to various sizes while maintaining a consistent visual hierarchy

Hey there, I'm struggling to achieve the same row size of images as shown in the example. However, when I adjust the window size, the larger images become smaller than the columns on the left. This has been a challenge for me and I haven't found ...

Unlimited scrolling feature on a pre-filled div container

Looking for a way to implement infinite scroll on a div with a large amount of data but struggling to find the right solution? I've tried various jQuery scripts like JScroll, MetaFizzy Infinite Scroll, and more that I found through Google search. Whi ...

Trouble in connecting local CSS stylesheet

I am facing an issue with adding my .css file to my project. Even though I have tried various methods, the styles are not being applied properly. When I directly embed the style code in HTML, it seems to work fine. This leads me to believe that the proble ...

How can you eliminate a line from the HTML input mask in Gravity Forms?

With Gravity Forms, I am utilizing the "input masks" feature to prompt users to enter data in a specific format. However, it seems to be creating an unwanted line within the input field itself as shown in the image below: https://i.stack.imgur.com/8gQ3K.j ...

Currently utilizing Yii framework to customize the appearance of a DIV element by specifying the CSS properties within the View, and subsequently storing the CSS file

I am looking for a way to allow users to customize the properties of a parent div, such as color, background, and other CSS styles, directly from the WordPress theming dashboard interface. Can someone please guide me in the right direction? ...

The skipping of crucial text in tab focus is adversely affecting the accessibility of the website

My appbar contains an image link, a warning indicating the user's current environment, and details about the logged-in user. While testing accessibility with a screen reader, I noticed that tab focus skips over the user details in favor of a link in ...

Creating a custom blockquote style for a WordPress Twenty Fifteen child theme

Currently, I am creating a new child theme for Twenty Fifteen completely from scratch. The one area I am struggling with is customizing the appearance of the blockquote using CSS. Here is an example of the custom CSS I have added to the blockquotes within ...

Adding dynamic images to Bootstrap Popover on the fly

Does anyone have suggestions on how to effectively retrieve the image from the data-img attribute in order to use it for a popover displaying product images? Thank you! <a href='#' class='toggle-popover' title='Hello World&apos ...