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

What is the best way to align a modal with a layout when it appears far down the components hierarchy?

Struggling with creating a React modal and facing some issues. Let's consider the structure below: React structure <ComponentUsingModal> <Left> <ButtonToActivateModal> ... </ButtonToActivateModa ...

Styling the CSS tables with alternating row styles for rows 1 and 2, followed by a different style for rows 3 and 4. This pattern will repeat

I've been struggling to create a CSS table style using tr:nth-child to alternate row colors: Row 1 - Blue Row 2 - Blue Row 3 - White Row 4 - White ... and so on. I can't seem to get it right! Can anyone help me out with this? Appreciate an ...

Fix the positioning of a div in BootStrap and CSS code

Hey there, I'm relatively new to CSS/Bootstrap and currently in the process of learning. I might need to incorporate some CSS into the "chat_funcs" div, but unsure about what code to input to achieve my desired outcome. The issue at hand: What I am ...

What is the process for creating a clickable file upload in Angular?

Currently, I am utilizing the instructions found in this guide to implement a file upload feature in my project. The code provided works perfectly: <input type="file" class="file-input (change)="onFileSelected($event)" #fileUplo ...

Horizontal alignment of Bootstrap columns is not working as expected

While attempting to integrate Bootstrap elements into my portfolio, I encountered issues with aligning columns. Currently, the only columns I have added are in the "welcome-section" (Lines 40-52), but they refuse to align horizontally. I've tried tro ...

Strategies for aligning a div element in the middle of the screen

Positioned in the center of the current viewport, above all other elements. Compatible across different browsers without relying on third-party plugins, etc. Can be achieved using CSS or JavaScript UPDATE: I attempted to use Javascript's Sys.UI.Dom ...

Creating a dynamic text design using Bootstrap or CSS: What's the best approach?

I attempted to enable responsive font sizes in Bootstrap 4.3.1 by setting the $enable-responsive-font-sizes variable to true, but I did not see any changes. Below is the code from my template.html file: <div class="m-2" id="role" ...

What is the best way to ensure a div is always scrollable?

I am currently working with Angular 4 and Bootstrap 4 (alpha 6). I have implemented ngx-infinte-scroll to fetch data from the server when the user scrolls to the top or bottom of the div. The issue I am facing is that the user can only scroll when there ar ...

The separator falls short of spanning the entire width of the page

For some reason, I can't seem to make the divider extend to the full length of the page. <TableRow> <TableCell className={classes.tableCell} colSpan={6}> <Box display="grid" gridTemplateColumn ...

Images in the JavaScript menu are not remaining fixed in place

Can someone help me with my website? I'm having trouble with the menu for different pages, it should stay gray for the active page. It was working fine before I switched to Wordpress, but now I'm not sure what the issue is. Could someone take a ...

Difficulty with NodeJS, Hapi, and Cascading Style Sheets

I've decided to challenge myself by creating a small webhost using Node.js with hapi. Even though I'm not an expert in Node.js, I am eager to learn as much as possible. Currently, my main issue revolves around fetching a CSS file from an include ...

In ReactJS, ensure only a single div is active at any given moment

I'm working on a layout with three divs in each row, and there are multiple rows. Only one div can be selected at a time within a row, and selecting a new div will automatically unselect the previously selected one. Here is a simplified version of my ...

css - design your layout with floating div elements

I used to design layouts using tables, but now I'm trying it out with divs. However, I'm still struggling to get the layout right. It's not as straightforward as using tables. For instance, my code looks like this: var html_output = "< ...

Having difficulty in getting a hyperlink to open in a new tab with _blank attribute

I'm currently working with this code for my link. <a href="https://dribbble.com/jamesfrewin"><img class="socialicon" src="images/icons/dribbble_dark.png" onmouseover="this.src='images/icons/dribbble_pink.png'" onmouseout="this.src= ...

Using HTML input checkboxes in conjunction with a JavaScript function

After creating a basic payment form using HTML/CSS/JS, I wanted to implement checks on user inputs using HTML patterns. In addition, I aimed to display a pop-up alert using JS to confirm the form submission only after all necessary inputs are correctly fil ...

Is there a more efficient method to achieve this task using JavaScript or jQuery?

Here is the code snippet I am currently using: $(document).ready(function() { //Document Ready $(".examples .example1").click(function() { $(".examples .example1 div").fadeToggle("slow"); $(".examples .example1").toggleClass('focused') ...

CSS - Placeholder styling not being effective when selectors are grouped

Why is Chrome successful at executing this code: .amsearch-input::-webkit-input-placeholder { color: red; } <input class="amsearch-input" placeholder="It works!" /> ...while it doesn't work in other browsers: .amsearch-input::-we ...

Tips for displaying JSON data by formatting it into separate div elements for the result object

Having recently started using the Amadeus REST API, I've been making AJAX calls to retrieve data. However, I'm facing a challenge when it comes to representing this data in a specific format and looping through it effectively. function showdataf ...

Start up a server-side JavaScript instance utilizing Express

My journey into web programming has led me to learning JavaScript, Node.js, and Express.js. My ultimate goal is to execute a server-side JavaScript function (specifically a function that searches for something in a MySQL database) when a button is pressed ...

Tips for maintaining color on <a> tags even after they have been clicked

My webpage has 3 <a> tag links to 3 different pages. I have set the hover state color to red, and now I want the background-color of the clicked page to remain as it was in the hover state. How can I achieve this? <html lang="en"> < ...