What could be causing the disappearance of my <Div> when applying a Class to the contained <span>?

My goal is to showcase a variable on my HTML page using CSS for a Graphical display in OBS streaming software. Whenever I apply the class .wrappers to the span id p1Name (and p2Name), the text disappears from the HTML output in OBS. I'm puzzled as to why the text vanishes; it displays perfectly fine without including the class .wrappers.

I've attempted tweaking page settings, class specifications, and relocating the object, but the text continues to disappear.

Edit Adjusting the opacity within wrappers has no impact on the object's visibility.

//Time stuff
let time = document.getElementById("current-time");

setInterval(() => {
  let d = new Date();
  time.innerHTML = d.toLocaleTimeString(navigator.language, {
    hourCycle: 'h23',
    hour: '2-digit',
    minute: '2-digit'
  });
}, 1000);
@font-face {
  font-family: "Futura";
  src: url('Resources/Fonts/Brandon_bld.otf');
}

* {
  margin: 0;
  padding: 0;
  font-family: "Futura";
  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;
}

.graphicBox {
  position: absolute;
  width: 1800px;
  height: 105px;
  background: rgb(51, 116, 182);
  background: linear-gradient(90deg, rgba(51, 116, 182, 0.75) 0%, rgba(110, 83, 180, 0.75) 70%);
  border-radius: 15px;
  bottom: 40px;
  left: 50px;
  filter: drop-shadow(-2px 2px 4px black);
}

.statusBox {
  position: absolute;
  font-family: "Futura";
  font-weight: bold;
  padding-top: 8px;
  font-size: 40px;
  width: 130px;
  height: 70px;
  background: rgb(231, 231, 231);
  border-radius: 15px;
  text-align: center;
  bottom: 125px;
  left: 100px;
  filter: drop-shadow(-2px 2px 4px black);
}

.timeDisplay {
  width: 140px;
  height: 30px;
  display: flex;
  align-items: left;
  justify-content: center;
  position: absolute;
  font-size: 14px;
  color: white;
  bottom: 58px;
  left: 771px;
}

.timeZone {
  width: 60px;
  height: 20px;
  display: flex;
  align-items: left;
  justify-content: space-between;
  position: absolute;
  font-size: 15px;
  color: white;
  bottom: 40px;
  left: 812px;
}

.scoreboardP1 {
  position: absolute;
  left: 150px;
  bottom: 60px;
  width: 300px;
}

.scoreboardP2 {
  position: absolute;
  left: 450px;
  bottom: 60px;
  width: 300px;
}

.wrappers {
  position: absolute;
  width: 340px;
  height: 100px;
  line-height: 54px;
  top: 356px;
  opacity: 0;
  color: black;
}

#p1Wrapper {
  bottom: 540x;
  left: 300px;
  color: white;
}

#p2Wrapper {
  width: 300px;
  bottom: 20px;
  left: 100px;
  color: white;
}

.scoreDisplay {
  position: absolute;
  color: white;
  width: 60px;
  height: 60px;
  align: center;
  font-family: "Avant";
}

#p1Format {
  top: 30px;
  left: 1160px;
}

#p2Format {
  top: 30px;
  left: 1450px;
}

.scoreBox {
  position: absolute;
  width: 45px;
  height: 45px;
  background: white;
  border-radius: 10px;
  align: center;
}

#p1Box {
  top: 28px;
  left: 1150px;
}

#p2Box {
  top: 28px;
  left: 1440px;
}
<div class="graphicBox">
</div>

<div class="statusBox">
  <p>NEXT</p>
</div>


<div class="timeDisplay">
  <h1 id="current-time"></h1>
</div>



<div class="timeZone">
  <p>EST</p>
</div>


<div id="overlayP1" class="scoreboardP1">
  <span id="p1Wrapper" class="wrappers">
            <span id="p1Name" class="names"></span>
  </span>
</div>

<div class="scoreboardP2">
  <span id="p2Wrapper">
            <span id="p2Name" class="names"></span>
  </span>
</div>

Answer №1

The issue appears to stem from the CSS class .wrappers.

Since .wrappers utilizes the property position: absolute, the element was vanishing off the screen. Moreover, with the attribute opacity: 0, the item becomes invisible.

To address this, I have commented out these aspects in the CSS:

  .wrappers {
    /* position: absolute; */
    width: 340px;
    height: 100px;
    line-height: 54px;
    top: 356px;
    /* opacity: 0; */
    color: black;
  }

Now, I am able to view both p1Name and p2Name when the parent spans p1Wrapper and p2Wrapper are assigned the wrappers class, as shown here:

<span id="p1Wrapper" class="wrappers">

Furthermore, a few brief points to note:

  • align: center is not a valid CSS property.
  • During testing, I inserted the text "testp2" within the p1Name span to observe formatting changes:
    <span id="p2Name" class="names">testp2</span>

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

Incorporating SQLSRV results into clickable <td> elements: A dynamic approach

As a newcomer to the world of JS/PHP/web development, I'm seeking help with a seemingly simple task. My goal is to make each <td> element in a table clickable, and retrieve the text contained within the clicked <td>. Currently, I have a S ...

Refreshing a specific div within an HTML page

I am facing an issue with the navigation on my website. Currently, I have a div on the left side of the page containing a nav bar. However, when a user clicks a link in the nav bar, only the content on the right side of the page changes. Is there a way t ...

Placing a Div wrapper around the contents of two corresponding elements

I am currently attempting to wrap a div with the class name 'wrapped' around two other divs containing innerHTML of 'one' and 'two'. <div class='blk'>one</div> <div class='blk'>two</di ...

Expanding rows in Angular UI-Grid: Enhancing user experience with hover functionality

Struggling to add a hover effect to the rows in an Angular UI grid. The goal is for the entire row to change background color when hovered over, but with an expandable grid that includes a row header, applying CSS rules only affects either the row header o ...

Elements shifting positions based on the size of the window

I am facing an issue with positioning the register form on my website. I want it to be fixed at the bottom-right corner of the window, without reaching the top. Although I managed to achieve this, the problem arises when the screen resolution changes. For ...

Struggling with eliminating the bottom margin on your website?

I can't figure out where this mysterious margin is coming from in the CSS - there's a consistent 30px of space at the bottom of each web page. Any assistance would be greatly appreciated. I know it's probably something simple, but my brain ...

Creating a series of menu image buttons with rollover effects using HTML and CSS

I am facing an issue with my navigation bar. I have 5 horizontally aligned .png buttons that I want to add rollover effects to using CSS, not Java. After trying multiple solutions, I still can't seem to get it right. None of the methods I attempted w ...

Trouble with Metro UI Library: CSS not loading properly

I am having trouble with the navbar CSS on my website while using the Metro UI CSS library. Check out my HTML code: <!DOCTYPE html> <html lang="en"> <head> <title>TelePrint Blog</title> <link rel="stylesheet" href= ...

What is the most effective way to extract information from a .txt file and showcase a random line of it using HTML?

As a newbie in HTML, my knowledge is limited to finding a solution in C#. I am attempting to extract each line from a .txt file so that I can randomly display them when a button is clicked. Instead of using a typical submit button, I plan to create a custo ...

Tips for preventing a column from extending beyond the edge of the browser window during resizing

Issue arises when I resize the browser window, causing the left box to extend beyond the browser boundary, making it impossible to see the contents even with the scrollbar below. <!DOCTYPE html> <html lang="en"> <head> ...

My challenges with optimizing positioning in Media Queries for Hover Buttons

After completing the coding for all Smartphone devices, I moved on to working on Tablets. However, I encountered an issue during this process as I am unsure of how to fix it. Here is a preview of my "Section Skills" layout for mobile: View Section on Mobi ...

Resolving the issue of nested modals within Bootstrap

I am experiencing some issues with my customer visits list page. When I try to add a visit, it opens a bootstrap popup ("#Pop1") to record the visit details. Within this modal, there is an option to add a new customer on the spot, which then triggers anoth ...

The URL is unresponsive following the deployment of the production build in tailwind

The image URL in my project is functioning correctly in the VITE server environment before the production build. However, after the production build, it fails to display the correct path of the image in the HTML. All other images are displaying properly ex ...

Display when moving up and conceal when moving down

Is there a way to make the div appear when scrolling up and down on the page? I'm new to jquery and could use some assistance, please. ...

Learn how to hide a bar after clicking the "I agree" button with the help of Bootstrap

click here to see imageIs there a way to make that bar disappear once the user clicks "I agree"? I've searched through Bootstrap documentation but couldn't find a solution. Please assist. Below is the code snippet: <div id="cookie-message" cl ...

Is it possible to include additional transformations to a div element?

Is it possible to add additional rotation to a div that already has a transform applied? For example, can I do the following: <div style="width: 200px; height: 200px; background-color: red; transform: rotateX(90deg) rotateY(10deg)" id="myDiv">< ...

What is the best way to format a date input field so that when a user enters a year (yyyy), a hyphen (-

Need help with date formatting in the format yyyy-mm-dd. Seeking a way to prompt user input for the year and automatically append "-" to the date as needed. Also utilizing a datepicker tool for selecting dates. ...

Using the "align" attribute is considered outdated and not recommended in HTML5 documents

I have encountered an error when using the align attribute. How can I fix this issue with the correct HTML5 compatible syntax? <table style="margin: 0 auto;"> <tbody> <tr> <td><input typ ...

How to store selected checkbox values in an array using AngularJS

Check out this code snippet: <tr ng-repeat="doc in providers"> <td><input type="checkbox" ng-true-value="{{doc.provider.Id}}" ng-false-value="" ng-model="ids"></td> </tr> {{ids}} I am trying to store the values of ...

I'm puzzled as to why the hidden input field consistently returns the same value every time

As a beginner in php, I am facing an issue where I cannot trace the correct value of the hidden input which represents the ID of the image in the products table. Every time I try to delete an image, it always returns the ID of the last image in the product ...