Adjusting the opacity overlay color in CSS

Is it possible in CSS to specify a different color for the overlap of two opaque elements? For instance, can I make two yellow elements that overlap turn orange at their intersection point?

Answer №1

At the moment, achieving this effect purely with CSS is not possible. There is a CSS property called mix-blend-mode that simulates Photoshop blending modes, but it lacks widespread support. Additionally, the outcome of the blending mode is reliant on the colors of the elements involved, and you cannot specify a specific color for the overlapping sections.

div {
  height: 100px;
  mix-blend-mode: multiply;
  position: absolute;
  width: 200px;
}

.left {
  background: cyan;
  left: 0;
}

.right {
  background: yellow;
  left: 150px;
}
<div class="left"></div>
<div class="right"></div>

Answer №2

It seems that achieving this purely through CSS is not possible. You may want to check out the following resources for more information:

How to create a transparent element that overlaps other elements?

https://css-tricks.com/equidistant-objects-with-css/

If you're still facing difficulties, consider applying CSS at runtime using JavaScript or creating a specific CSS class with selectors like 'first' or 'last' as suggested in the second link.

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

Ways to condense a text by using dots in the middle portion of it

How can I dynamically shorten the text within a container that varies in width? The goal is to replace the strings between the first and last words with dots so that it fits within the container. For example, Sydney - ... - Quito. It should only replace wh ...

The CSS Validator does not recognize the CSS pointer-events and appearance properties

I'm a CSS beginner who recently created an app. I've encountered some errors and warnings when validating my CSS code: https://i.stack.imgur.com/g4MUz.png https://i.stack.imgur.com/Es1DE.png Could someone kindly explain these errors and warnin ...

The offspring selector and the after pseudo-element

So, I have this CSS snippet here: .nav-item > .nav-link:not(.active)::after { content: "test"; display: block; width: 0; border-bottom: solid 2px #019fb6; transition: width .3s; } But now, I want to try something different: .nav-ite ...

How can you activate color printing in CSS when using ng-style in AngularJS?

My application generates data in a table, where each cell has a unique combination of background color and text color determined by its properties. The code to achieve this is simple: ng-style='{"background-color": lt.backgroundColor, "color": lt.te ...

Ant Design: Incorporating margin and padding causes slight rendering glitches in the markup

https://i.sstatic.net/BWmFU.gif https://i.sstatic.net/ZaLH8.gif When I apply margin and padding to this class, it starts twitching like in the first GIF. Removing the margin and padding fixes the issue, but I need them for styling. What is causing this ...

Choose items in a particular order based on the class name of their category

How can I dynamically select and manipulate groups of elements? My intention is to select and modify the msgpvtstyleme elements, then select the msgpvtstyle elements separately and work with them as well. The ultimate goal is to apply classes to these grou ...

Influence of External Style Sheet not reflected in HTML

Just as the title suggests, I have an external style sheet connected to my HTML document, and it appears that the footer element may be incorporating the changes, but none of the other content is. Being new to this, I'm trying to pinpoint where I went ...

Is there a way for me to view the specifics by hovering over a particular box?

Whenever I hover over a specific box, detailed information appears, and when I move the mouse away, the details disappear. HTML <nav> <div> <div class="nav-container"> <a href="./about.html" ...

Reposition DIV elements using only CSS styling

I'm attempting to switch the positions of two divs for responsive design (the website appearance changes based on browser width, ideal for mobile). Currently, my setup looks like this: <div id="first_div"></div> <div id="second_div"&g ...

CSS not displaying properly

I've been working on a React.js web app with Material UI components. The challenge I'm facing is with one specific component that handles the website management and displays a preview of custom content. This website, unlike the rest of the app, u ...

Remove all of the classes from the specified element using JavaScript

I have a button and I want to remove all the classes when it is clicked. Here is what I have tried: button.style.className = '' document.querySelector('button').onclick = function() { this.style.className = ''; } .myClas ...

What is the best way to conceal a `div` containing an error message if there are no errors present?

On this page, you'll find a server-side and client-side validation form. I'm currently using a div id=er> to display error messages when the requirements are not met. However, having the div element always present is causing styling issues for ...

What is the best way to navigate from one div to a particular slide within a slider?

Let's say I have two web pages: index.html and page.html. On page.html, there is a slider with 9 slides created using the plugin StackSlider. Now, when a link on index.html is clicked, I want to navigate to a specific slide, like slide number 4, on pa ...

Easily transition the header's height when selecting a menu item

I am trying to achieve a collapse effect or something similar However, when I click on a menu item, the height changes too quickly without any animation What could be wrong in my code? I am looking to reference an effect similar to the one seen in the h ...

Highcharts 7 - Positioning an Annotation in the Center

I would like to display an annotation above specific data points on my Highchart. Currently, the annotation appears at the location of the data, but it is not centered directly over the point. I want the annotation to be perfectly centered on the data poin ...

Header displayed on each page. (WordPress)

(my website: ) I am using Wordpress.org and I am trying to create a button that will redirect the user back to the front page, but I am having trouble figuring out how to do it. The button should be located in the top left corner of the site and should not ...

ensure all items in the list have consistent width

Looking to create a straightforward menu bar using the ul tag with 4 links. The ul spans 100% of the screen width, so each li element should be 25%. I attempted to implement this, but the final list item ends up dropping to the next line. However, setting ...

Issue with z-index in Internet Explorer version 7

Currently, I have implemented a drop-down list using jQuery that activates when the user hovers over the main menu. This functionality is working appropriately in all browsers except for IE7 and earlier versions. In an attempt to ensure the drop-down menu ...

Can changes made to an element's style in Firebug be automatically applied to the unminified CSS/LESS files?

Is it possible to efficiently modify a page with minified stylesheet and see the changes reflected back in the source code using smart IDEs, F12 tools, and 3rd party plugins or software? I typically create basic CSS, test it on the browser, tweak styles u ...

Parent element unable to trigger event due to interference from child elements

Within my HTML document, there is a parent <span> element that contains nested <em> elements. This <span> is styled with a specified width and display:block property using CSS. Despite a jQuery trigger event being successfully fired on t ...