What is the best way to insert a triangle shape to the bottom of a div with an opacity level set at 0.2

https://i.stack.imgur.com/sqZpM.png

I've been trying to create something similar, but my triangle keeps overlapping with the background in the next section. I've already spent 3 hours on it. Any help would be greatly appreciated.

Check out my code here

Answer №1

Check out this cool polygon design, feel free to customize the colors

div.container {
  display: inline-flex;
  align-items: center;
  position: relative;
  background: black;
  width: 100%;
}

div.tangle {
  height: 50px;
  width: 200px;
  clip-path: polygon(0% 20%,
                  60% 20%,
                  95% 20%,
                 100% 50%,
                  95% 80%,
                  60% 80%,
                   0% 80%);
}

div.tangle:nth-child(1) {
  background:lightgreen;
  transform: translateX(20px);
  z-index:3;
}
div.tangle:nth-child(2) {
  background:green;
  transform: translateX(10px);
}
div.normal {
  height: 30px;
  width: 200px;
  background: white;
}
<div class="container">
  <div class="tangle"></div>
  <div class="tangle"></div>
  <div class="normal"></div>
</div>

Answer №2

To achieve this effect, you can utilize the ::before and ::after pseudo-elements. One will serve as the background for the 'next step', while the other will create the triangle with the background color of the 'current step'.

I opted for simple li elements without a tags, but it can easily be modified to accommodate a elements if needed.

It is recommended to avoid using opacity for step differences. Instead, use direct hex codes for better accessibility rather than adjusting opacity levels of a single hex code.

To prevent color bleeding, space out the li elements with margin and utilize the before/after pseudo-elements to fill in the gaps. This approach is preferable over overlapping elements to ensure that clicking on covered areas does not cause any issues.

Answer №3

Your stackbliz example has been enhanced with my edits. Be sure to take note of the alterations made to both the HTML and CSS.

Avoid using opacity for color lightening; instead, utilize SCSS's lighten and darken functions.

Make the most of CSS for styling by leveraging existing classes rather than modifying the HTML structure extensively.

REMEMBER: Make use of SCSS variables, nesting, and built-in functions.

Implemented a reverse z-index to stack elements in order from previous to next.

There are a total of 6 elements below.

[ngStyle]="{
 zIndex: 6 - i
}"

Here is the updated link to your stackbliz example.

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

The paintbrush is whimsically altering its style on the canvas

My checkerboard has a unique feature where hovering over a tile will highlight it in yellow. Surprisingly, this action also turns the game border and the last white checker's border yellow as well. What's puzzling is that I never specified for t ...

Why is the size of my array shrinking with every iteration of the for-loop in JavaScript?

I am struggling to change the classname of three elements that share the same classname. Unfortunately, as I loop through my array, it seems to decrease in size with each iteration, preventing me from successfully changing all three elements. Any advice or ...

When hovering over a hyperlink, an image appears but I want to adjust the image's position in relation to each link

I have a unique feature on my website where text hyperlinks reveal small thumbnail images when hovered over. This concept was inspired by an example I found on this page. I initially implemented the code from a post on Stack Overflow titled Display Image O ...

Adjust the size of the Div and its content to fit the dimensions of

Currently, I have a div containing elements that are aligned perfectly. However, I need to scale this div to fit the viewport size. Using CSS scale is not an option as it does not support pixel values. https://i.stack.imgur.com/uThqx.png I am looking to ...

The HTML checkbox is initialized as checked when the page loads

Is there a way to set the checkbox as unchecked in HTML? I have tried multiple ways, but it always loads as checked <input id="chkBox" checked type="checkbox" /> <input id="chkBox" checked=false type="checkbox" /> <input id="chkBox" checked ...

Guide on accessing js file in an Angular application

I have a component where I need to create a function that can search for a specific string value in the provided JavaScript file. How can I achieve this? The file path is '../../../assets/beacons.js' (relative to my component) and it's named ...

How can you use jQuery to select and manipulate multiple form inputs with a common class?

I am currently working on a program that requires at least one of various form inputs to have data in order for the user to submit the form. I was able to successfully code for a scenario with only one input field, but I am facing a challenge when it comes ...

what is the process for creating a dynamic display slide in bxslider?

I am trying to create a flexible length display using bxSlider. Here is the code I have so far. JS var duration = $('ul > li > img').data("bekleme"); $(document).ready(function () { $('.bxslider').bxSlider({ ...

Discovering modifications to CSS using selenium

Currently, I am working on an ajax form where CSS elements are dynamically changed. I am curious to know if it is feasible to verify these changes using Selenium. For example, checking if the background color changes from #ffffff to #000000 after clicking ...

The art of bringing a pseudo class to life through animation

Seeking assistance with achieving a unique effect on click event. I have set up a slanted or razor-blade style div using a parent div element and a pseudo-element :after (as shown below). My goal is to change the skew angle when the user clicks on the pare ...

Dimming the background of my page as the Loader makes its grand entrance

Currently, I am in the process of developing a filtering system for my content. The setup involves displaying a loader in the center of the screen whenever a filter option is clicked, followed by sorting and displaying the results using JQuery. I have a v ...

Managing iframes in React using reference methods

Trying to set the content of an iframe within a React component can be a bit tricky. There is a component that contains a handleStatementPrint function which needs to be called when the iframe finishes loading. The goal is to print the loaded iframe conten ...

Tips for implementing the same autocomplete feature across multiple form fields

Struggling to add multiple products and provide auto-suggest for each product name? You're not alone. It seems like the auto suggest feature is only working for the first product. Can anyone point out what's going wrong here? Here's my HTML ...

What is the best way to collapse additional submenus and perform a search within a menu?

Whenever a sub-menu is activated, only the current sub-menu should be open while the others remain closed. I need the search function to be enabled on the text box and display all items containing the specified value while also changing the color of <a ...

What is the syntax for implementing an if-else statement?

Just starting with algolia and looking for a hit template. Please take a look at the script below for the text/html template needed: <script type="text/html" id="hit-template"> <div class="hit"> <div class="hit-image"> <i ...

callbacks in amazon-cognito-identity-js

When working with amazon-cognito-identity-js, I encountered an issue with the callback function. This is what it currently looks like: cognitoUser?.getUserAttributes((err, results) => { if (err) { console.log(err.message || JSON.stringify(err)); ...

Customizing the colors of Angular Material themes

Currently, I am looking to completely change the theme of my angular 8 application. Within a scss file, I have the following code: @import '~@angular/material/theming'; // Plus imports for other components in your app. // Include the common st ...

The sub-menu is being obscured by a PDF element in Internet Explorer, causing visibility issues

I have an object type tag on my page that displays a PDF file. Everything is functioning correctly, but in Internet Explorer, my sub-menu is being hidden behind the object tag. var objTag = $('<object></object>') .attr({ data: source ...

Associate a template reference variable with an attribute directive category

Currently, I am in the process of creating an attribute directive that will receive multiple templates containing additional data for filtering. This extra information will be utilized later to select the appropriate template. To achieve this, I have exten ...

What is the best way to link assets within an Angular custom element (Web Components)?

After successfully creating a web component and referencing an image from my asset folder, everything was running smoothly on my local environment. However, when I published my custom element to Firebase hosting, I encountered some issues. When trying to ...