How can I use CSS3 to design a unique custom shape that fits this specific style?

I have some detailed graphs, but I want to display them using CSS shapes. I've been attempting to create css3 shapes that match my graphics (see attached image), but without success.

How can I replicate these graphics?

https://i.sstatic.net/2pxaW.png

This is my attempt:

<div class="container">
    <div id="triangle-red"></div>
    <div id="triangle-blue"></div>
    <div id="triangle-yellow"></div>
</div>

#triangle-red {
    width: 0;
    height: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-bottom: 100px solid red;
}

#triangle-blue {
    height: 0;
    width: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-top: 100px solid blue;
}
#triangle-yellow 
{
    width: 0;
    height: 0;
    border-top: 50px solid transparent;
    border-right: 100px solid yellow;
    border-bottom: 50px solid transparent;
}

View demo online

Note: Based on the values of each combination, I intend to calculate the height and width according to the data received. It's similar to creating a graphical representation.

Answer №1

To begin, you will need a total of 6 div elements.

Each div should be in the shape of a triangle. To create this effect using CSS, refer to this resource.

You can achieve the rotation with transform:rotate(xdeg).

For creating shadows, simply adjust the color of each div accordingly.

To prioritize the red divs over the blue ones, utilize z-index.

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

Revive your Chart JS visualization with interactive re-animation via onclick action!

I've been exploring Chart.js and trying to achieve something simple, but I'm having trouble. I just want the chart to re-animate when clicking on a button, but I can't seem to make it work. I attempted to attach chart.update to the onclick e ...

There is a problem with my module where multiple files that require it are overriding its variables

Currently, I am working on developing a mongo connection pool factory that is capable of checking if a connection to mongo already exists. If a connection exists, it will return that connection. However, if there is no existing connection, it will create a ...

Executing a JavaScript function with Selenium

I encountered this issue on a website. div class="accept" onclick="javascript:ClosePopup(true);" ... When I execute "ClosePopup(true)" in the browser console, the button functions correctly and closes the popup. In Selenium, I attempted something like ...

Matching nodes to selectors is a breeze with Angular JS and jqLite

Currently, I am in the process of integrating a few jQuery functions into jqLite to avoid loading the entire jQuery library when working with my angular applications. Following the approach outlined by Ben Nadel in his insightful article. However, I have ...

Incorporate duration into date using angular

In my Firebase database, I store the following information: Timestamp for the day a record was created in Firebase. Terms entered by the user at the time of creation. For instance, it may look like this: 1439612582756 // converts to: Aug 14, 2015 15 / ...

Risks associated with working with position:relative and left/top in web development

When using position: relative; with multiple elements, are there any potential issues to be aware of? Unlike position: absolute;, which may not display correctly on different monitors. For example: <img src="blah.png"/ class="someClass"> <im ...

Using a directive to implement Angular Drag and Drop functionality between two tables with 1000 records

My code is functional, but there seems to be a delay in the appearance of the helper(clone) when dragging starts. I have two tables - one for the include list and another for the exclude list. Users can drag table rows from the include table to the exclud ...

Having trouble submitting the edit form

I had the idea to create an edit form that would replace the existing data in a table for editing. However, I am facing issues with getting the form to submit properly even though the create form is functioning correctly. Below is the code snippet that I n ...

How can I extract the id of a clicked item and pass it to a different page with Jquery?

Facing an issue where the attribute value of a clicked href tag is not retained after browser redirection. Initially, when clicking on the href tag, the value is displayed correctly. However, upon being redirected to the peoplegallery_album, the id becomes ...

What is the best way to ensure that a mapped type preserves its data types when accessing a variable?

I am currently working on preserving the types of an object that has string keys and values that can fall into two possible types. Consider this simple example: type Option1 = number type Option2 = string interface Options { readonly [key: string]: Op ...

When attempting to send an archiver file in NodeJS, the request may become unresponsive

In my NextJS application, I am facing the challenge of generating a large number of QR codes at once, like 300, 400, or even 500, and then packaging them into a zip file for users to download. The following code snippet demonstrates how I achieve this usin ...

What are the steps for loading JSON data into a select dropdown with the help of AJAX?

I am trying to create a dropdown list of schools using the select tag. Currently, I have hard coded values for the list, but I want to fetch the data from a RESTful service instead. Can someone please provide guidance on how to achieve this? <html& ...

Route in Node.js for event binding

Currently, I am using expressjs in combination with nowjs and binding some events to the now object directly within the route when it is accessed. However, this approach feels messy and I am concerned that every time the route is accessed, the events are e ...

JavaFX GridPane: Automatically adjust size when content is hidden or disabled

Is it feasible to reduce the size of a GridPane row if the content in that row is both disabled and invisible? Even when a Node is set to disable=true and visible=false, the cell continues to occupy space. If I have 8 rows but only the first and last are ...

Need to import a custom module using npm and TypeScript

Exploring two projects: main-project and lib-project, both written in TypeScript and compiled to common JavaScript using gulp. Our objective is to require lib-project in main-project. lib-project |-- package.json |-- gulpfile.js |-- dist |-- index.js ...

Searching for data between two specific dates can be achieved in Laravel Vue by utilizing the filter

I've successfully implemented a search feature for normal fields in my form. However, I'm encountering difficulty when trying to search within a date range. Here's my controller code: public function index() { $query = Matter::query(); $qu ...

It appears that Promise.all is not adequately ensuring that all tasks are completed before moving on

In my current project, I am trying to achieve a complex cycle where an HTTP GET request is executed to fetch data, followed by the creation of multiple "subrequests" based on that data. The goal is to ensure that the next iteration of the cycle begins only ...

Struggling with aligning rows containing three divs each in Rails and bootstrap

Looking to display 3 article divs in each row on my website using bootstrap 3 grid system: <div class="container-fluid"> <h1>NEWS</h1> <div class="row"> <% @articles.each do |article| %> <div class="col- ...

Optimizing Spacing in HTML and CSS Navigation Bars

Newbie Alert: HTML/CSS Help Needed! Hello, I am currently working on revamping this navbar for practice. The current version of my navbar can be seen here. Here is the snippet of my HTML code: <!DOCTYPE html> <html lang="en"> &l ...

What do you call a software application that relies on a dependency for its functioning?

As I work on updating a package, other software that relies on it as a dependency has led me to wonder what to call them from the perspective of the dependency. While not exactly peer dependencies due to the modular design of the dependency in question, I ...