CSS styling failing to meet desired expectations

Two different elements from different panels are using the same CSS styles, but one displays the desired text while the other does not. The CSS file in question is named grid.css.

To see the issue firsthand on my live website, please visit:

I am uncertain whether the problem lies with the JavaScript linked to the element or if video files inherently cover text, so I have shared the full website for easier debugging purposes. Here is the corresponding GitHub repository: https://github.com/kaweepatinn1/kaweepatinn1.github.io

Despite attempting various modifications to the CSS settings and inspecting the element in Developer Tools, I cannot identify the source of the issue since one element behaves flawlessly with seemingly identical CSS code.

The problematic HTML excerpt is as follows:

      <a href="TO SET">
<div class="applead grid-item" onmouseover="regifApple()" onmouseleave="revertApple()">
<img class="img" id="appleimage" width="100%" height="auto" src="./static/assets/applead.webp" alt="Applead Image">
  <div class="img-caption">
    <div class="vid-title">
      Mock Apple Ad
    </div>
    <div class="vid-director">
      Animation and Motion Graphics
    </div>
  </div>
</img>
</div>
</a>
<a href="TO SET">
  <div class="OYYGC grid-item" onmouseover="regifOYYGC()">
  <video class="img" id="OYYGCimage" width="100%" height="auto" src="./static/assets/OYYGC.mp4" loop muted="muted" alt="OYYGC">
    <div class="img-caption">
      <div class="vid-title">
        Oh Yeah You Gonna Cry?
      </div>
      <div class="vid-director">
        Animated x Live Music Video
      </div>
    </div>
  </video>
  </div>
  </a>

The relevant CSS classes are defined as:

.grid-container {
    display: grid;
    grid-template-columns: auto auto auto;
    justify-content: space-evenly;
  }

.grid-item{
    height: 17w;
    margin: 1vw;
}

/* Remaining CSS class definitions can be found above */

If necessary, the associated JavaScript functions are included below:

var mouseOverApple = false;
var mouseWasGoneApple = true;

// Remaining JavaScript functions omitted for brevity

Answer №1

When working with HTML, it's important to note that you cannot directly nest a <div> element inside a <video> tag. The purpose of the <video> element is specifically for displaying video content and does not support block-level elements like <div>.

If you need to overlay content on top of a video or position content around a video element, there are alternative ways to structure your HTML code.

To address this issue, simply move the div tag with class="img-caption" outside of the <video> tag as shown below:

<a href="TO SET">
    <div class="OYYGC grid-item" onmouseover="regifOYYGC()" bis_skin_checked="1">
        <video class="img" id="OYYGCimage" width="100%" height="auto" src="./static/assets/OYYGC.mp4" loop="" muted="muted" alt="OYYGC"></video>
        <div class="img-caption" bis_skin_checked="1" style="pointer-events: none;">
            <div class="vid-title" bis_skin_checked="1">Oh Yeah You Gonna Cry?</div>
            <div class="vid-director" bis_skin_checked="1">Animated x Live Music Video</div>
        </div>
    </div>
</a>

Include the CSS code snippet below to ensure proper functionality:

.OYYGC .img-caption {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.OYYGC .img-caption .vid-director {
  bottom: 15px;
}

Answer №2

The issue arises from placing the img-caption within the video element, causing it to display only if the user's browser does not support the video tag.

According to the source code in your repository, you should use the following structure instead:

<div class="OYYGC grid-item" onmouseover="regifOYYGC()">
  <video class="img" id="OYYGCimage" width="100%" height="auto" src="./static/assets/OYYGC.mp4" loop muted="muted" alt="OYYGC"></video>
  <div class="img-caption">
    <div class="vid-title">
      Oh Yeah You Gonna Cry?
    </div>
    <div class="vid-director">
      Animated x Live Music Video
    </div>
  </div>
</div>

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

Tips for causing a single span tag within a group of multiple tags to overflow its parent element

Is there a way to make the highlight span sit just after the to without affecting the width of the parent, and without using absolute positioning? I would like the span to be aligned with the example "to" and overflow outside of the parent container. Thank ...

Is it possible to retrieve and display an object from an API using its unique ID?

I created a straightforward application. The main page displays a list of movies fetched using an API, and upon clicking on a particular movie, it leads to a new page with detailed information about that movie. On the details page, another API call is ma ...

Splitting JavaScript Arrays: Exploring Efficient Division

I'm attempting to develop a recursive function that divides an array in half until it only consists of lengths of 3 and 2. After dividing, I want to neatly organize all the new arrays into another array. My idea is to find a way to determine the numb ...

What is the process of including a CSS class in a NAV anchor tag on WordPress?

I recently started using Bootstrap 4 and have structured my menu in the following way: <ul class="navbar-nav mx-auto justify-content-center"> <li class="nav-item"> <a class="nav-link" href="index.php">HOME</a> </ ...

Running a setTimeout function within the context of a jQuery each

My goal is to animate characters one by one, but for some reason the following code isn't functioning as expected: $('.overlay-listing').hover(function(){ var idx = 1; $('.strip-hov span', this).each(function(){ if ...

Applying the jqtransform plugin to all forms except for one

We've implemented the jQuery jqtransform plugin to enhance the appearance of our website's forms. However, there is one particular form that we'd like to exclude from this transformation. I made adjustments to the script that applies jqtrans ...

Tips for maintaining the webcam video in the center of the screen even when the height is set to 100% and the window is being resized

When using React, I encountered an issue with centering a webcam video while maintaining its height at 100% of the screen. Although the video fills the screen vertically correctly, adjusting the width of the window causes the video to lose its centered pos ...

Tips for showing ng-repeat items solely when filters are applied by the user

Is there a way to only display elements when a user uses a filter? For instance: $scope.elements = [{name : 'Pablo', age : 23}, {name : 'Franco', age : 98}]; <input type="text" ng-model="searchText" /> <div ng-repeat="elemen ...

Changes to the parent state will not be reflected in the child props

When the child component PlaylistSpotify updates the state localPlaylist of its parent, I encounter an issue where the props in PlaylistSpotify do not update with the new results. I've been struggling to figure out what I'm missing or doing wrong ...

Is there a way to simulate pressing a keyboard button using jQuery?

Below is the code snippet: $("input").on({ keydown: function(ev) { if (ev.which === 27){ // esc button backspace_emolator(); } else if (ev.which === 8){ // backspace button console.log('backspace button ...

"Learn an effective method for presenting JSON variable data in a Bootstrap modal with a clean design using three distinct columns

I have successfully loaded JSON data into my HTML page using JQuery. By clicking a button, I can trigger a bootstrap modal that displays the content of the JSON variable. However, there is an issue with how the JSON data is displayed. I need the data to b ...

Tips for organizing list items in a grid format using CSS and HTML

In my div block, the width is not fixed. Inside the div, there is a list block with 11 items that I want to display evenly like this: ##item## ##item## ##item## ##item## ##item## ##item## ##item## ##item## ##item## ##item## ##item## I&a ...

The CSS transition duration is not being applied properly on the initial transition effect

Looking to create a dynamic set of sliding divs that can be triggered with the press of a button. Each div will contain a thumbnail image and accompanying text. The goal is to enable the user to navigate through the content by clicking the left or right bu ...

Retrieve the current date and time in JSON format using moment.js for the local

Below is the code snippet I am working with: var startTime = moment("2020-09-08 16:00:00").toDate(); console.log(startTime) const data = {start: startTime} console.log(JSON.stringify(data) After running it, the result is as follows: Tue Sep 08 ...

Two liquid level divs within a container with a set height

I hesitated to ask this question at first because it seemed trivial, but after spending over 3 hours searching on stackoverflow and Google, I decided to give it a shot. The issue I'm facing can be found here: http://jsfiddle.net/RVPkm/7/ In the init ...

TinyMCE - Optimal Approach for Saving Changes: keyup vs onChange vs blur

In the context of my Filemaker file, I am utilizing the TinyMCE editor. My goal is to automatically save any changes made by the user, whether it's typing, applying formatting, inserting an image, or making any other modifications. I have a function ...

Ways to eliminate spacing between two select boxes?

Hey everyone, I'm sure we've all encountered this issue before and can agree that it's pretty annoying. Does anyone have a solution for removing the white space from select boxes? <select> <option> testing </option& ...

The conditional CSS file does not have precedence over the regular CSS file

Currently, my approach involves using conditional comments to connect to a CSS file named "IEonly.css" if the Internet Explorer version is not greater than 8. My goal is to modify certain properties in the standard CSS file. Oddly enough, IEonly.css effect ...

Creating beautiful user interfaces with Material UI and React

I'm currently exploring how to integrate Material UI into my React project. After successfully installing the module, I attempted to create a custom button component. Here is my Button.js file: import React from 'react'; import FlatButton ...

The test may detect a variable that was not initialized

I'm trying to understand why I get the error message "variable may not have been initialized" when testing (variable === "some text"), but I don't receive the same error when using (typeof passwordHashOrg !== 'undefined') The code that ...