Overlay Labels in Bootstrap

Looking for help with a div containing some html that creates a complex graph. The goal is to add labels at the top and bottom of the graph, overlaying the graph div, while covering 10% of the top and bottom areas of the graph div.

In the mock example below, only the bottom label appears properly. How can I overlay the top label on the graph div? What element am I missing? Can this be accomplished as a percentage of the graph div area?

<div class="position-relative">
    
    <div style="position:absolute; z-2"> 
        <h2 style="background-color:grey;" >Top Label</h2>
    </div>
    
    <div style="height:100px; width:100px; margin-top:40px; margin-left:20px; background-color:red; position:absolute;">
        GRAPH
    </div>
    
    <div style="height:100px; width:100px; margin-top:90px; 
    background-color:orange; position:absolute; z-1;">
        <h2>Bottom Label</h2>
    </div>
</div>

Answer №1

It is important to remember to use the proper CSS property z-index instead of simply using z. When elements do not have a specified z-index, they will default to their stacking order in the HTML, with lower elements rendering on top. To address this issue, you have two choices:

  1. Utilize z-index: 2 instead of z-2
  2. Alternatively, you can ensure the correct display order in your HTML by positioning labels directly after the chart.

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

Having trouble retrieving dynamic data from a JSON array

I am working with a JSON array. JSON.stringify(ar) When I attempt to display the results in an alert: alert(JSON.stringify(ar)); The output displayed in the alert is: [{"url":"link1","title":"title1"}] However, when I try to transfer the contents i ...

The customization of jQuery UI Slider is failing to function as expected

In my quest to create a customized jQuery slider, I encountered the need to change the background of the slider handle. After experimenting with some code on this link, I am still unable to achieve the desired effect. Following the documentation, I have a ...

What sets siblings apart from children?

Trying to decipher the code snippet referenced in this post has got me puzzled. Why is it that Children are used instead of Siblings in this case? I can grasp the concept of Children referring to nested tags, but what exactly does Siblings signify? $(&apo ...

Preserving form POST information between form handler and header invocation

I've hit a roadblock with this issue and could use some assistance. Thank you in advance for any help. I have a form on a page (guest/build.php) that contains several radio buttons: <form action="../php/build.php" method="POST"> <table class ...

Creating a variable within an Angular template: A step-by-step guide

I'm working with the following template: <div> <span>{{aVariable}}</span> </div> and I want to transform it into: <div "let a = aVariable"> <span>{{a}}</span> </div> Is there a way to ach ...

What are the steps for specifically editing the mobile version of a website?

I am currently gaining experience by working on a website, but I am facing some challenges in making changes specifically for the mobile version. Here is an example: <h1 class="intro-header__title"> <span>Are you ready to</span> Expa ...

Using a .NET Web-API controller variable as a parameter in a JavaScript function

I am looking to send a "variable" from the controller to a JavaScript function. The code I have implemented is as below: <div ng-controller="faqController"> <div ng-repeat="c in categories"> <h2 onclick="toggle_visibility(&apos ...

List items are loaded dynamically in an unordered fashion

I have been working on a jquery slider using flickerplate. Below is the code that works when the values are hardcoded: <div class="flicker-example"> <ul> <li data-background="lib/flicker-1.jpg"> <div class ...

Is it just me, or does the float left - float right combination only break in IE

Oh dear, it seems like IE9 is causing some trouble again. The other "capable" browsers handle this HTML just fine, including IE8 which isn't even that great. Here's the code snippet: <div class="contact_info_city" id="contact_info_cityX"> ...

Issue with Global styles causing conflicts with Grommet styled-components styles

I attempted to update my current App to utilize Grommet for the Inputs. The transition went smoothly, but I encountered a problem with the styles. Because the react-App is embedded on various pages, I have to contend with various types of global css style ...

Text displayed over an image using Bootstrap 5

I'm a beginner with Bootstrap 5 and I have a question about how to position text inside an image, similar to the first screenshot provided: https://i.sstatic.net/HVdie.jpg I tried using card-img but it didn't work. I also attempted to use cols, ...

Preventing Internet Explorer from automatically scrolling to the top of the page when a new HTML element is dynamically inserted using

On my webpage, I have an ASP:Grid with a small copy button in each row to copy the text inside that cell. The javascript function I created for copying the text is as follows: var copyText = function (textToCopy) { $(".copy").append("<textarea id=&ap ...

Is there a way to create a sequence where text fades in only after the previous text has completely faded out?

Currently, I am using JQuery to create a continuous slideshow of text values. However, after some time, multiple texts start to display simultaneously, indicating a timing issue. Even when hidden, the problem persists. My code includes 3 strings of text. ...

Guide on utilizing slider arrows for enabling Twitter Bootstrap tabnav controls

Previously, I sought help with an issue regarding a Navtab not being highlighted when active. The problem persists despite successfully configuring the slider to swipe to the corresponding slide upon selecting a tab. Specifically, if I manually slide fro ...

What is the code to create a forward slash on a webpage using HTML/CSS?

I want to create a unique parallelogram/slash design on my website. While it's simple to place two rectangles side by side, achieving the slash effect is proving to be quite challenging. Can this be done using only CSS or HTML, or does it require SVGs ...

Stacked PNG's in an HTML design

Has anyone been successful in stacking 3 layers of png images on a table? I am attempting to achieve this with a table that has 6 columns. Grey Arrow - Serving as the table background image Red Arrow - Representing a PNG within the table Blue Arrow - Ind ...

Steps to align an SVG to the right within a div

I'm struggling to get an SVG to align at the end of its containing div. The div is set to display in flex and I've tried using "align-self: flex-end" on the a tag that wraps the svg, as well as experimenting with block and float-right. Any sugges ...

A variable in Javascript storing data about jQuery DOM elements

Currently, I am using the slick slider for my development (http://kenwheeler.github.io/slick/) In JavaScript, there is an event that returns a variable called 'slick' When I print the variable using console.log, this is what I see: https://i.s ...

The Google Rich Result Testing Tool encountered an issue: Parsing error detected - a '}' or object member name is missing

Visit my website: www.bharatpharmatech.com I have implemented my code using Next.js Here is the schema I am utilizing: { "@context": "https://schema.org/", "@type": "WebSite", "name": "Bharat Pharmate ...

What is the best method for choosing all elements located between two specific elements?

If I have the following HTML code, what CSS selector can I use to target all elements between #one and #two without using jQuery? <p id="one"></p> <p></p> <p></p> <p></p> <p></p> <p></ ...