create a layout with intersecting divs to display a table/chart

Lately, I have been pondering how to achieve a design similar to the one shown below. Specifically, I am interested in the "sparkline/area" chart that appears at the bottom of the table/divs.

I can't seem to figure out how to code something like this. The way the chart data overlaps each div is particularly confusing to me. Would using a table be the solution?

If anyone could offer some guidance or provide a quick code example demonstrating how to create this overlapping effect, it would be greatly appreciated.

If this question is not appropriate for Stackoverflow, please excuse my mistake.

Answer №1

Utilize z-index to adjust the positioning of an element relative to other elements:

HTML

<div class="container">
    <div class="row">
        <div class="col">One</div>
        <div class="col above">Two Above</div>
        <div class="col">Three</div>
        <div class="col above">Four Above</div>
        <div class="col">Five</div>
    </div>
    <div class="bottomOne"></div>
    <div class="bottomTwo"></div>
</div>

CSS

.container{
    width:500px;
    height:150px;
    position:relative;
}

.row{
    width:500px;
    height:150px;
    background-color:gray;
}

.bottomOne{
    position:absolute;
    bottom:0px;
    left:0px;
    width:500px;
    height:50px;
    background-color:red;
    opacity:0.5;
    z-index:1;
}

.bottomTwo{
    position:absolute;
    bottom:0px;
    left:0px;
    width:500px;
    height:30px;
    background-color:blue;
    opacity:0.5;
    z-index:10;
}

.col{
    float:left;
    background-color:lightgray;
    width:98px;
    border:1px solid gray;
    height:148px;
    position:relative;
    text-align:center;
    line-height:100px;
    font-weight:bold;
}

.col.above{
    z-index:5;
}

To bring a column forward, simply apply the 'above' class to the row.

Check out this example for reference:

jsFiddle demonstration

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 automatically select a checkbox when using ng-repeat on page

I'm looking to automatically check an input checkbox when the page loads, and if it's checked, subtract its value from the total. How can I tackle this issue? Here's the HTML snippet: <p>{{vm.TOTAL VALUE}}</p> <tr ng-repeat= ...

Converting JSON into key-value pairs using ReactJS

Here is a JSON object that I have: [ { "crime": "LARCENY-NON_VEHICLE", "count": "23217" }, { "crime": "AUTO_THEFT", "count": "13675" ...

Implementing a Singleton Pattern in ReactJS using Context API for Asynchronous Operations

My current implementation involves using a hook: function useFollowUser() { const isFollowing = useRef(false); return (userId) => { if(isFollowing.current) return; // mutual exclusion isFollowing.current = true; ... updat ...

Default file is still generated by Sass even when variables are modified

Currently, I am in the process of modifying some variables for my customized version of Bootstrap. At the moment, I have the Bootstrap SCSS files along with my own variables file. This is how my file appears: @import "/path/to/bootstrap"; $blue: #42a5f ...

On production, Heroku fails to load JavaScript files, only allowing CSS files to be loaded. However, the files load successfully when

I've been struggling to find a solution to my problem, so I'm reaching out for some help. I am in the process of deploying my node (express) app to Heroku, but I've encountered an issue where only CSS files from my public folder are being t ...

Steps to Activate Quill Editor on the Document Object Model (DOM) Post Cloning

I've created a rather intricate page layout where users can add blocks dynamically to the dom. Each block contains a Quill editor, which is functioning correctly. However, I'm facing an issue when trying to edit the content once it's been co ...

Transforming jquery code into Angularjs code

I am currently working on a jQuery method that adds a 'selected' class to table rows and handles click events. Here is the code: $('.niGridTable table tr').addClass('selected').end().click(function (event) { event = ...

Can the current website navigation be integrated into the blog script?

People might see me as a spoil sport for not using Wordpress, but I prefer a flatfile blog system for my small site. Currently, I am using the ozjournals-3.2 blog system. I need assistance in installing a header and site navigation on top of the blog page ...

What is the best way to incorporate options using jQuery?

Currently, I am incorporating a jQuery plugin for modals into my website. The plugin/code offers the functionality to customize the background color of the modal. For more details on how to do this, you can visit the plugin's official website. Althou ...

What is the best way to refactor this jQuery code without duplicating it?

I have a design with three layers, where two are initially hidden using CSS. My goal is to toggle the visibility of these layers based on which input field the user is focused on: The three layers I am working with are: #titleBox, #phoneBox, #addressBox, ...

Why is there an error when trying to assign Type '{}' in generics typescript?

I'm having trouble understanding why this code is causing an error. The error message says - Type '{}' is not assignable to type 'Keys<T>'. type Keys<T extends string|symbol>={ [key in T]: string; }; const foo = < ...

Can anyone suggest an effective method for displaying images using JavaScript by specifying a route and filename?

Currently, I have the following code snippet: const route = '/Images/Banner/'; const slides = [ { name: "banner-01", url: `${route}banner-01.png` }, { name: "banner-02", url: `${route}banner-02.pn ...

The v-select function organizes data based on the content of "item-text"

I created a v-select component using Vuetify, and I am wondering how I can sort the names of the items from largest to smallest within this v-select? <v-select v-model="selectedFruits" :items="fruits" label="Favorite Fruit ...

There is an issue with my HTML due to a MIME type error

I am currently facing an issue with my project. I have developed a node js server and now I want to display an HTML file that includes a Vue script loading data using another method written in a separate JS file. However, when I attempt to load the HTML f ...

The presence of a Bootstrap addon is resulting in horizontal scrolling on mobile devices within the webpage

I am encountering a peculiar issue with an input-group in my cshtml file which features a Bootstrap addon. The problem arises on mobile devices, where upon focusing on the input field, the page scrolls horizontally to the right, revealing the right margin ...

Adjust the contents of a DIV depending on which Toggle button is selected

When a user clicks on either "Twin Bed" or "King Bed", the content inside the "demand-message" should change to either "high demand" or "Only ??? rooms left". The ID will remain the same for both buttons due to existing logic. However, the message display ...

Update the content within a document and implement jQuery to make it clickable

Within my webpage, there is a random occurrence of the word -FORM-. I am looking to replace this word with another text that includes dashes for creating a clickable div. Despite having some code that successfully replaces the text, it lacks the function ...

Iterating through a collection of objects, triggering a promise for each object and recording its completion

I have encountered a challenge where I need to iterate through an array of objects obtained from a promise, and for each object in the array, I must invoke another promise. After all these promises are executed, I want to display "DONE" on the console. Is ...

Safely transmitting client-side encrypted information between individuals

I am developing a service that will keep personal information about a specific user, which should only be accessible by the author and the intended recipient. I want to encrypt the data on the client-side and store the encrypted version on the server. Res ...

Is there an issue with Vue-router 2 where it changes the route but fails to update the view

I am currently facing an issue with the login functionality on a website that utilizes: Vue.js v2.0.3 vue-router v2.0.1 vuex v0.8.2 In routes.js, there is a basic interceptor setup router.beforeEach((to, from, next) => { if (to.matched.some(record ...