Instructions on how to place a label within the box (see image below), such as labeling a red box with the text: "2 problems"

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

It is important to note that the color red should be labeled "2 Issues," the yellow box should say "4 Issues," and so on. I have encountered difficulties in applying CSS to achieve this effect.

In the code below, I attempted to add labels but faced issues with getting them to display inside the boxes; I am unsure which attribute should be used for this purpose:

content += "<tr rowspan = \"3\"><td><div class=\"project-name\">"+args.chart.chartWidth[i].project+"</td>";
content += "<td colspan = \"5\"><div class=\"box-container"+i+"\"><div class=\"box"+i+" red" +i+ "\"></div><div class=\"box"+i+" yellow" +i+ "\"></div><div class=\"box"+i+" green" +i+ "\"></div></div></td></br></tr>"; 
content += "<style type=\"text/css\"> ";
content +=".box-container"+i+"{   padding: 10px;display: table-cell;text-align: center;vertical-align: middle; }";
content +=".box"+i+"{float: left; box-shadow:3px 3px 2px #666767; height:30px;}";
content += ".red" +i+" { width: " + redWid + "px; background-color:#ff0000; **label:"2Issues"** }";
content += ".yellow"+i+" { width: " + yellowWid + "px; background-color:#ffff00; **label:"3Issues"**  }";
content += ".green"+i+" { width: " + greenWid + "px; background-color:#00ff00; **label:"4Issues"** }"; 

Answer №1

By inserting the content inside the div elements with colors red, green, and yellow, you can reveal the hidden label within the container.

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

Conceal a div depending on the selected radio button within a form

On my form, there are two radio buttons to choose from: one for "yes" and the other for "no". I am looking to create a feature that will hide a specific div on the form when the "no" option is selected. I have tried various JavaScript solutions found onlin ...

Tips for retrieving a variable from a $.getJSON function

My question is similar to this one: How can I return a variable from a $.getJSON function I have come across several duplicates on Stack Overflow, but none of them provided a satisfactory answer. I understand that $.getJSON runs asynchronously, and I hav ...

Encountering a Blank Area at the Top of a Printed AngularJS Screen

Currently, I am tackling an issue in AngularJS while working on the Print Invoice Page. The problem I am encountering is a blank space at the top of the printed screen. Check out the image here Below is my code: HTML <div id="invoice" class="compact ...

reduce opacity of specified div background

Objective / Purpose I am working with multiple div elements and I want to assign two distinct classes to each of them, each serving a different purpose within my application. One class should determine the level, influencing the color of the div. The oth ...

Struggling to fetch option value from a dynamic add/remove list using a combination of PHP, jQuery, and HTML5

Having trouble accessing and displaying values from a select list. Constructed an add/remove list functionality using JQuery but unable to showcase the values using foreach and for loops. Specifically trying to obtain $existing_mID[$j] values from the &apo ...

Place objects at the bottom of the screen

I'm currently using Bootstrap 4 and facing an issue where I want to keep a row with some columns at the bottom of the page. However, when I add position fixed and set it to bottom, the placement gets disrupted and does not stay centered. I suspect thi ...

Ways to implement two distinct background color changing features

Is there a way to reset mouseover after mouseout for changing the background color of an element on mouseover, mouseout, and onclick events in Javascript? function init() { document.getElementById('default').onmouseover = fun ...

Design a unique border for a div element that extends a top-border all the way through the header and a bottom-border that

I am trying to achieve the design displayed in this mockup: https://i.sstatic.net/sYEPu.png Here is my current progress: https://codepen.io/raney24/pen/VOmjBY .header-border { width: 100%; margin-bottom: 10px; border-left: red solid 1px; border ...

$shade "shade" is not a shade in Material Design

Whenever I attempt to incorporate variables into the Bootstrap SCSS theme map, an error occurs. This is how my SCSS looks: https://i.sstatic.net/RLH7M.png The specific error that I encounter is shown here: https://i.sstatic.net/IFthc.png ...

I wonder what the response would be to this particular inquiry

I recently had an angular interview and encountered this question. The interviewer inquired about the meaning of the following code snippet in Angular: code; <app-main [type]="text"></app-main> ...

Perform an AJAX request to an encrypted URL with an unverified certificate

I'm experiencing an issue with my site that makes AJAX JSONP calls to a secured (SSL) web server. Everything works smoothly when using an unsecured (HTTP) web server, but once I switch to the SSL version, the call never returns. After checking with Fi ...

My initial attempt at writing JavaScript proficiently

I have been working on JavaScript using jQuery for some time now, and while I can make it work as needed, I realize that I haven't really focused on writing reusable or modular code. Now, I am determined to take the next step and master the art of cra ...

Display inconsistency noticed in Wordpress Carousel for images

This particular issue revolves around how images are displayed in the Wordpress Carousel. To see the problem in action, visit the product page linked below: When you navigate to this page, do not click on any of the pictures. Instead, select an option fro ...

The configuration "react-app" failed to load, hindering the ability to extend it while working on the project

After creating a react app using yarn create react-app, I ran yarn start and the project loaded fine on localhost. However, any edits made to a file (such as adding a new tag or renaming the contents of a div) caused the app to throw an error during compil ...

Connecting CSS and JS files in JSP was a bit of a challenge

Just starting out with jsp and using Glassfish server via netbeans. Struggling to link my jsp file with css and javascripts. Below is the structure of my files: Web Pages --Web-Inf --assets --css --style.css --js --jquery.js ...

Executing two AJAX requests simultaneously with Django, AJAX, and jQuery in a single event

I believe I'm on the right track to getting this to work, but I could really use some assistance with the JQuery aspect. It seems that everything functions as expected after the second click onwards, but there is an issue with the functionality on the ...

Utilizing Promise chains within React for making REST API requests

I am currently working on a React application and I am relatively new to React, so I would appreciate some guidance in the right direction. My application involves building components that rely on making various Rest API calls to fetch the necessary data ...

Why isn't the flash message appearing until after I refresh the page or make a second post?

After revisiting Sails.js, I decided to implement flash messages in my app for errors, successes, and alerts. While searching for a solution, I came across this discussion which provided some helpful suggestions that I integrated into my code. Although th ...

Create new <div> elements dynamically within a loop using the value of a variable as a condition

I am in need of assistance with a function that generates news tiles ("cards") as displayed below: renderNews = <div className={styles["my-Grid-col"] + " " + styles["col-sm12"]+ " " + styles["col-md12"] + " " + styles["col-lg12"] + " " + styles["col-xl ...

JavaScript - Adjusting Size of Images in Slideshow

My current project involves creating a slideshow in JavaScript where I only want to display half of the images. However, I have encountered an issue with some images having a width and height equal to 0 specifically in Chrome and Opera browsers. What could ...