Unable to make boxes responsive to size changes in CSS when layered over video background

I am struggling to position my boxes on top of a video background in HTML/CSS. Despite my efforts, the boxes only appear at the bottom and do not move with any CSS adjustments I make. Is there something I am missing or doing wrong in my approach? I want to use a video as the background, but I'm unsure if it's possible to set a video as the background directly in CSS. Any guidance is appreciated.

/* font-family: 'Sedgwick Ave'; */
@import url('https://fonts.googleapis.com/css2?family=Sedgwick+Ave&display=swap');

/* font-family: 'Bebas Neue' */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap');

/* font-family: 'Nunito' */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@200&display=swap');

#myVideo {
    position: fixed;
    right: 0;
    bottom: 0;
    min-width: 100%;
    min-height: 100%;
  }

* {
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    max-width: 100%;

    /*     border:1px solid red; */
}

/*General Styles*/
html,body {
    font-size: 62.5%;
    /* background-image: url('/images/home-page-bg-black.jpg'); */
    width: 100%;
    height: 100%;
}

.container {
    height: 100%;
    width: 100%;
}


nav {
    position: relative;
    height: 100vh;
    text-align: center;
    display: flex;
    justify-content: space-evenly;
  }

nav a{
    text-decoration: none;
    font-size: 2.2em;
    color: white;
    margin-top: 2%;
    font-family: 'Bebas Neue';
}

.boxes{
    display: flex;
    justify-content: space-evenly;
    flex-wrap: wrap;
}

.box{
    background-color: red;
    position: relative;
    width: 10%;
    height: 80px;
    display: flex;
    align-content: center;
}

.box h4{
    text-align: top;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Portfolio</title>
    <link rel="stylesheet" href="styles/index.css">
</head>

<body>
    <div id=".container">
            <video autoplay muted loop poster id="myVideo">
                <source src="/images/Cyberpunk1-1 (2021_04_28 20_59_30 UTC).mp4" type="video/mp4">
            </video>
        <nav>
            <a href="#" id="nav-home">Home</a>
            <a href="#" id="nav-about">About</a>
            <a href="#" id="nav-project">Projects</a>
            <a href="#" id="nav-contact">Contact</a>
        </nav>
        <div class ="boxes">
            <div class="box"> <h4>TEXT HERE</h4></div>
            <div class="box"> <h4>TEXT HERE</h4></div>
            <div class="box"> <h4>TEXT HERE</h4></div>
            <div class="box"> <h4>TEXT HERE</h4></div>
        </div>
    </div>
</body>

</html>

Answer №1

Are you satisfied with this solution?

List of Modifications:

  1. Change the class name to
    <div class="container">
  2. Add these lines in CSS for .boxes
    position: absolute;
    top: 0;
    left: 0;
  1. Add some internal spaces in CSS for .box
padding: 10em;

/* font-family: 'Sedgwick Ave'; */
@import url('https://fonts.googleapis.com/css2?family=Sedgwick+Ave&display=swap');

/* font-family: 'Bebas Neue' */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap');

/* font-family: 'Nunito' */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@200&display=swap');

#myVideo {
    position: fixed;
    right: 0;
    bottom: 0;
    min-width: 100%;
    min-height: 100%;
}

* {
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    max-width: 100%;

    /*     border:1px solid red; */
}

/*General Styles*/
html,body {
    font-size: 62.5%;
    /* background-image: url('/images/home-page-bg-black.jpg'); */
    width: 100%;
    height: 100%;
}

.container {
    height: 100%;
    width: 100%;
}


nav {
    position: relative;
    height: 100vh;
    text-align: center;
    display: flex;
    justify-content: space-evenly;
  }

nav a{
    text-decoration: none;
    font-size: 2.2em;
    color: white;
    margin-top: 2%;
    font-family: 'Bebas Neue';
}

.boxes{
    display: flex;
    position: absolute;
    top: 0;
    left: 0;
    justify-content: space-evenly;
    flex-wrap: wrap;
}

.box{
    background-color: red;
    position: relative;
    width: 10%;
    height: 80px;
    display: flex;
    align-content: center;
    padding: 10em;
}

.box h4{
    text-align: top;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Portfolio</title>
    <link rel="stylesheet" href="styles/index.css">
</head>

<body>
    <div class="container">
            <video autoplay muted loop poster id="myVideo">
                <source src="https://www.w3schools.com/html/movie.mp4" type="video/mp4">
            </video>
        <nav>
            <a href="#" id="nav-home">Home</a>
            <a href="#" id="nav-about">About</a>
            <a href="#" id="nav-project">Projects</a>
            <a href="#" id="nav-contact">Contact</a>
        </nav>
        <div class ="boxes">
            <div class="box"> <h4>TEXT HERE</h4></div>
            <div class="box"> <h4>TEXT HERE</h4></div>
            <div class="box"> <h4>TEXT HERE</h4></div>
            <div class="box"> <h4>TEXT HERE</h4></div>
        </div>
    </div>
</body>

</html>

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

Transferring data from JavaScript to PHP for geolocation feature

Hello everyone, I'm looking to extract the longitude and latitude values from my JavaScript code and assign them to PHP variables $lat and $lng. This way, I can retrieve the city name and use it in my SQL query (query not provided). Below is the scrip ...

Is there a simpler method to access the source element for an event?

I'm just starting to learn JavaScript and jQuery, and right now I have the following code in my HTML: <a id="tog_table0" href="javascript:toggle_table('#tog_table0', '#hideable_table0');">show</a> After that, I hav ...

Tips for creating multiple functions within a single JavaScript function

Is there a way to combine these two similar functions into one in order to compress the JavaScript code? They both serve the same purpose but target different CSS classes. The goal is to highlight different images when hovering over specific list items - ...

Tips for positioning the overlay to match the icon list when hovering- JavaScript/Cascading Style Sheets (CSS)

My challenge involves a list of <li>'s accompanied by an icon that, when hovered over, displays an overlay containing information about the 'test'. The setup looks something like this: test1 test2 test3 and so forth.... Here' ...

In which location are HTML files stored within WordPress plugins?

Can someone help me locate the HTML files within WordPress plugins? I'm looking to make edits to the HTML and CSS files of a plugin, but I can't seem to find the specific HTML file. Any guidance on where these files are stored would be greatly ap ...

Open HTML Frameset in a new tab or window

I've been contemplating for the past week on how to address my issue using frameset. Situation: I have an html file for header, footer, menu, and content, each with its own background color. I implemented a frameset for enhanced design. The header ...

Safari alters the header color on mobile devices

Debugging this issue has been quite challenging - the number at the top of the page appears in white before changing to a dark grey on iPad and iPhones running Safari. Why is this happening?! It functions correctly on all other devices! Check out www.col ...

Can the parent document interact with Shadow DOM elements?

When it comes to user-created shadow DOM elements, this question focuses more on accessibility using the date input type: For instance, let's say there is a date input on a webpage. After some editing, the shadow DOM markup for this element (in Chrom ...

Content within a scrollable div in IE7 only loads once the user starts scrolling

TL;DR: How can I make IE7 load all hidden elements within a scrollable div? I'm creating a collapsible menu for easy navigation through a series of pages. This menu has two states: collapsed and expanded. Think of the menu items as chapters in a b ...

I am looking for a pair of HTML tags that will allow one to be visible while the other is hidden, and then switch when needed

I am in the process of constructing a webpage dedicated to learning Japanese vocabulary. Each word will be presented within a sentence, just like the example shown below. 森林に散歩する take a walk in the forest In order to facilitate the practic ...

Integrating content from a separate PHP page into the main index PHP page

I can't seem to get the #container1 div on my index.php page to load with the content from another #container2 div on page1.php. It's frustrating because I've checked my file hierarchy and everything seems correct. This is how my files are ...

Display data-content vertically using CSS

Looking for a way to display text vertically one by one with CSS? While the rotation method produces this result: https://i.stack.imgur.com/utAiN.png However, I aim to achieve something more like this: https://i.stack.imgur.com/fuVyb.png If you have an ...

Changing the order on mobile devices in Bootstrap 4: A quick guide

Currently, I am working on a responsive layout using Bootstrap 4 with two columns. Each column contains a total of 9 divs - four in the first column and five in the second column. My goal is to rearrange the order of the divs within the columns when the vi ...

jQuery Refuses to Perform Animation

I'm facing an issue with animating a specific element using jQuery while scrolling down the page. My goal is to change the background color of the element from transparent to black, but so far, my attempts have been unsuccessful. Can someone please pr ...

Is there a way to maintain the vertical alignment of spans within an HTML div after numerous drag and drop operations have taken place?

Recently, I created a JavaScript program (code provided below) to enable the dragging and dropping of <span> elements containing Greek characters within a basic <div> container. Upon initial page load, everything appears perfectly aligned vert ...

The issue with using HTML code inside a variable that is passed into a partial view is that the code is not being

I have created a partial view to show the page header, which takes in two variables - an Icon and a title. The code for pageHeader.blade.php is as follows: <div class="page-header"> <div class="row"> <!-- Page header, center on small sc ...

Performing calculations using jQuery and organizing sub-totals into groups

I am currently developing a web application and aiming to incorporate an invoice calculation feature with sub-groups. My goal is to have the total result of both group-totals and sub-totals at the end. Here is my progress so far: Check it out here $(func ...

The HTML Email Template fails to incorporate certain CSS styles

When attempting to create an HTML Email template that includes a button with a link and has a maximum width with consistent margins on both sides, I encountered some issues. While certain parts of the CSS were applied correctly, others were not displaying ...

Creating engaging animations for variable content in Safari using CSS

This multi-step wizard is designed to smoothly transition between its 3 steps. Upon clicking the "next" button in step 1, the content is pushed down to reveal step 2. Similarly, when advancing from step 2 to step 3, the contents of both previous steps are ...

Overlap of Bootstrap Columns Occurs When Resizing the Browser

While I recognize that this issue is common, I have extensively reviewed similar questions but could not find a solution. <div class="container"> <div class="row"> <div class="col-xs-12 col-sm-12 col-md-6"> <img style="wi ...