What is the most effective way to display a pixelated background video in the header section of my website, with text overlaying it?

Currently immersed in an HTML and CSS project, I aim to showcase a captivating background video sourced from Pexel that occupies the entire top section of the screen above the "hello" and "meet the team" sections (excluding the navbar). While my Codepen link is available below, here are the key areas where I suspect my errors lie.

HTML:

 <div class="all">

  <head id="home">
    <div id="welcome-section">
      <!-- The video -->
<video autoplay muted loop id="myVideo">
  <source src="pexels-magda-ehlers-5306154.mp4&" type="video/mp4">
</video>

<div class="content">
  <h1>Hello</h1>
</div>
    </div>

CSS:

      html, .all {
      margin:0;
      height:100%;
      box-sizing:border-box;
      background-image: url("https://m.media-amazon.com/images/I/41g8yeF0NWL._AC_.jpg");
       background-repeat: no-repeat;
     background-size:cover;
     background-attachment: fixed;
    }


#welcome-section{
   display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  font-size:50px;
  color:white;
  height:100vh;
  
}

/* Style the video: 100% width and height to cover the entire window */
#myVideo {
  object-fit: cover;
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
}

.content {
  position: relative;
  height: 100vh;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

Despite referencing these resources, I'm facing difficulties in getting the video to appear. Any guidance or support would be greatly appreciated!

Codepen:https://codepen.io/coder3o2-4/pen/ExXYeRY

Relevant Links:

https://css-tricks.com/full-page-background-video-styles/

https://www.w3schools.com/howto/howto_css_fullscreen_video.asp

Answer №1

Your code is functioning properly, although the specific goal you are trying to achieve is a bit unclear to me.

One issue in the codepen is that you have linked a video file that cannot be located. Where did you save your mp4 video? The src attribute of the video tag should point to the path of the video file on either your local or production server, such as /assets/video/myvideo.mp4. If you are unsure if the video is correctly linked, you can inspect your page using Chrome, right-click on the video URL, and select "open in a new tab". If the video plays, then it is linked correctly.

In addition, you may need to remove the background from the first section and adjust the z-index property for the video itself to ensure it is positioned "below" the other content on the z-axis.

In the image I am providing, I have linked a random video (the grass) to test if it works.

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

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

chosen=chosen based on data from mysql database

Currently, I'm developing my own CMS that allows users to add and update their projects. While the adding function works smoothly, the updating process also functions properly. However, a problem arises when I click on a project (retrieving informatio ...

Show the time variable from Django in the format of hours, minutes, and the AM/

Is it possible to use a time variable instead of a CharField for a model that displays multiple saved times? The issue I'm facing is that it shows as "9 am" instead of "9:00 am", and "noon" instead of "12:00 pm". Can anyone provide assistance with thi ...

Does the onChange event fire when the value is modified by the parent element?

let [number, set_number] = useState({x: 1}); <ChildComponent number={number} onUpdate={onUpdateFunction} </ChildComponent> set_number({x: 2}) After running set_number({x: 2}), will this action prompt the execution of onUpdateFunction refere ...

Creating a set width for the input-group-append division in Bootstrap 4

I am currently utilizing the power of Bootstrap 4's input group feature to position an icon next to an input field. My goal is to set a fixed width of 40px for the div containing the input-group-append (which houses the icon). According to the offici ...

Crafting CSS for styling input type file elements

My attempts to style the input type file with CSS have been unsuccessful. In my current code, the "choose file" button is displaying above my styled button. How can I use CSS to remove this? I am aiming to only display a blue colored button for uploading ...

Smoothly animate the height change of dynamically inserted content within a DIV using CSS transitions

Here is the template I am currently working with: <div class='content'> {{content}} </div> Along with the following style: .content { margin-top: 30px; background-color: skyblue; width: 300px; transition: all linear 0.5 ...

Retrieve information from a sensor within an Express server and display it on the user interface

Looking for suggestions on resolving a challenge: I have a Node.js module that retrieves data from a sensor, and I am interested in incorporating a UI element to showcase the sensor data (either in real-time or pseudo-realtime). Is there a way to establ ...

Delivering seamless css integration using express.js

Lately, I've been struggling with serving CSS using Express.js. After some trial and error, I managed to make it work. However, I'm puzzled as to why my new code works while the old one doesn't. Here's the code that now works for me: co ...

The content of the served HTML Table remains static and requires a server restart for any updates to

Having been encountering this issue for quite some time, I have searched extensively for a solution but to no avail. Therefore, I am taking matters into my own hands and posing the question myself. The dilemma is as follows: https://i.stack.imgur.com/UZrQ ...

How to conceal anchor text within a stretched link using the ::after selector in Bootstrap

I have a card layout where all cards are made clickable with a link using the bootstrap stretched-link class. However, I also added text to the anchor for SEO purposes, even though it doesn't make sense in a card layout. I wanted to hide the text whil ...

Converting SQL database tables into MVC webpages using JavaScript

Currently, I am working on populating an MVC webpage by utilizing a Controller and a View using C#, HTML, and Javascript exclusively. It is crucial that I avoid using a model or PHP due to the existing format in use. Thus far, all the data has been succes ...

The issue of app.css and app.js resources not loading in Laravel 8 with nginx, resulting in a 404 not found error, needs to be

Although this question may appear to be a duplicate, I assure you it is different. I have thoroughly searched through Stack Overflow, Laracast, Reddit, and GitHub for a solution. My setup includes a Laravel application on an Ubuntu VM with Nginx. The pro ...

Achieve the effect of making the Bootstrap JS Collapse text bold after it has been

Is there a way to make Bootstrap JS Collapse text Bold after it has been clicked on? <tr data-toggle="collapse" data-target="#demo8" class="accordion-toggle"> <td> <div class="fa ...

What could be the reason for my Bootstrap popover malfunctioning?

I've been attempting to incorporate the Bootstrap popover into my project. I copied the code exactly from the example provided on the website, but unfortunately, it doesn't seem to be functioning properly on my site. Below is the full code snippe ...

Is there a way to transform this fixed alignment of divs, etc. into a responsive layout that automatically adjusts to different screen sizes? - Using HTML and CSS3

If you want to see the demo, you can check it out on JSFiddle by clicking on this link: JSFiddle Demo. This webpage utilizes Twitter's Bootstrap framework, which you can find more information about by visiting . When inspecting the stylesheet on JSF ...

Link to database stored in MySQL and HTML within a URL reference

I am currently working on creating an image link that allows users to define a folder in their settings. Below is the code I am using: <?php if (strpos($current_user_meta['UserRank'], 'Admiral ') !== false ) { // get the use ...

Retrieve the html code from a PHP backend by utilizing core-ajax within the Polymer framework to store the information

Is there a way to retrieve JSON data from a PHP script that contains HTML tags, and display the data properly in an HTML format without seeing the tags? Currently, HTML tags are displayed as: <h1>hello</h1> instead of rendering as: hello I am ...

Make sure to include the !important declaration when setting the fill property for

When attempting to apply !important to the fill property of an SVG file, I'm encountering issues with the syntax. Despite my efforts, the !important directive is not being correctly applied to the fill property, resulting in the circle element renderi ...

Is it possible to utilize a tracking pixel (invisible GIF) as a background image within a stylesheet?

I'm curious to know if adding a tracking pixel (a transparent GIF with server logging) as a background-image in a linked stylesheet will have the same impact as if it were a regular <img> on a webpage. After conducting a quick test using Chrome ...

Information is not transferring to Bootstrap modal

I attempted to send a value to a modal by following the instructions on the Bootstrap documentation here. However, I am facing an issue where the data is not being successfully passed. To trigger the modal, use the following button: <button type=" ...