Is there a way to change the image in a fixed header to appear in negative color when scrolling, showing anything underneath it?

My website has a transparent fixed header with my company's black logo. I want the logo to change color whenever it overlaps with colored elements on the page, adapting to their negative color. Palantir also did something similar with their logo but eventually changed it.

I've searched extensively online for a solution and attempted using blend modes in CSS, but I must be missing something...

Answer №1

It seems that the mix-blend-mode CSS property could be of use in addressing your query. Here is a brief example showcasing its application (you have the freedom to experiment with various mix-blend-mode values to achieve the desired outcome):

div {
  position: fixed;
  mix-blend-mode: difference;
  
}
p{
  background-color: #666;
}
p.red{
  background-color: red;
}
p.green{
  background-color: green;
}
<div class="fixed">
  <img src="https://scontent.ftbs4-2.fna.fbcdn.net/v/t45.1600-4/338544317_6309992646707_2491776963105174437_n.jpg?stp=c220.0.540.540a_cp0_dst-jpg_p180x540_q75_spS444&_nc_cat=1&ccb=1-7&_nc_sid=de7202&_nc_ohc=VcmdAB7SScMAX8pdXJ2&_nc_ht=scontent.ftbs4-2.fna&oh=00_AfA1HReZ3Zayt6dX7kuNbxiGjoZ4N_LSCxKbp231d4lOoA&oe=6428C2F8" alt="">
</div>
<p>
  minima consequuntur vel deleniti ex, velit odio minus. Sunt, libero perspiciatis ex, deserunt ...
  <p class='red'>
     [...]
  </p>
  <p class='green'>
    [...]
  </p>
      [...]

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

Upon transitioning between router pages, an error message pops up saying "Vue Socket.io-Extended: this.$socket.$subscribe is not a

I have created a basic Vue application that is designed to connect to a NodeJS server using websockets. My setup involves the use of socket.io-extended for handling the connections. After following the documentation and implementing the websocket connect ...

Remove parent state using a child component

I currently have two class-based components set up. For the Parent Component: App import React, { Component } from 'react'; import Navbar from './Navbar'; import SearchBar from './SearchBar'; class App extends Component { ...

Transitioning from JQuery to JavaScript with Carousel Bootstrap 5

I would like to implement a bootstrap 5 carousel that displays multiple items and slides one at a time. My goal is to convert the existing Jquery code into pure Javascript so that I can eliminate the dependency on Jquery. I came across this solution which ...

Is there a way to determine whether there is an item located at a specific point on a grid?

Imagine a scenario where we have a grid with 5 columns and 3 rows as an example. However, the number of elements and their positions are unknown. https://i.sstatic.net/Ay0i3.png Consider that the only element on the grid is the red area. I am in need of ...

I am encountering an issue with the callback function not functioning properly when utilizing react-flutterwave-rave in test mode. What could

I have integrated Flutterwave as the payment system for my web application that I am currently developing using React. To facilitate this integration, I have utilized the react-flutterwave-rave package available on npm. The implementation is functioning ...

Utilizing the optimal method for aligning text to either the right or left side

I am currently working on creating a container element with multiple child elements. I would like these elements to be aligned differently, some left-aligned and others right-aligned. This includes scenarios where the child elements themselves are containe ...

In JavaScript, locate the closest element in an array based on its value, avoiding cases where the value exceeds the nearest element

I am trying to find the nearest element in an array based on a given value, but I specifically want it to be the nearest one that is greater than or equal to the value. For example, if I have an array like [3000, 5000, 8000], when I search for a number bel ...

Using a curly brace in a React variable declaration

After completing a react tutorial, I started customizing the code to suit my requirements. One specific section of the code involved a component that received a parameter called label. render() { const { label } = this.props; ... } For instance, I re ...

Can Child Component Changes in React Checkbox Cause Parent Node to Re-Renders?

Struggling with creating checkboxes for my project, I've spent an entire day on it without finding a solution. The issue involves a main checkbox that controls all child checkboxes. The desired functionality is to have the parent node's "allChec ...

`Cursor in ACE Editor jumping to start of the line`

Having a strange issue with my editor. Every time I type something, it automatically gets reversed because the cursor keeps jumping back to the beginning of the line. For example, if I type 'Say this', it appears as: :siht ekil puS On pressin ...

What methods can be used to modify the appearance of the cursor depending on its position?

Is there a way to change the cursor to a left arrow when on the left half of the screen and switch it to a right arrow when on the right half, using JavaScript? I am trying to achieve something similar to what is shown on this website. I attempted to acco ...

What's causing this issue in Internet Explorer?

I recently created a new website at Unfortunately, I'm facing an issue with Internet Explorer. Despite trying various workarounds, I can't seem to pinpoint the CSS error causing the bug. Why am I struggling to fix this? 1- I predominantly use ...

A guide on extracting a JSON object from an external file in React by utilizing .map() in ES6 along with a loop

I have been attempting to import a JSON object from an external file using React in order to display its contents within an HTML loop integrated into a JQuery Slider (Slick). While I believe I have successfully imported the JSON, I am facing difficulties ...

Steps to Remove an item from a JSON file using JavaScript

Trying to remove an object from a JSON file in JavaScript has proven to be more challenging than expected. Here is an example of the JSON file structure: { "tom cruise": { "player": "tom cruise", "team": "buf", "position": "q ...

What could be causing the discrepancy between the labels below the chart and the labels in the legend on the bar chart in Chart.js?

I'm looking to create a chart with labels on the xAxes and the same labels in the legend. I've tried various solutions, but so far, the best result I've achieved is shown in the code snippet below. However, all bars seem to be connected to m ...

Searching for values that do not begin with a specific set of characters using regular expressions

How can I create a regular expression for excluding words with a specific starting pattern? Consider the following list: January February June July October I need a regular expression that will match all words except "June" and "July" because they star ...

An application using AJAX that supports multiple languages

I am currently developing a web application that heavily relies on JavaScript and AJAX. One of the requirements for this app is to support multiple languages. For server-side translation, I have implemented a template engine in PHP which handles translati ...

What is the best way to fetch values from individual buttons using PHP?

<form action="posts-ayarlar.php" method="POST" id="demo-form2" data-parsley-validate class="form-horizontal form-label-left"> <table class="table table-striped table-bordered" ...

Utilize JQuery's 'each' method to showcase the value of an external

Can you show the value of a variable that is declared outside of a $.each loop inside the loop? For example: function updateTitle(row, title) { var rowElement = $(row); $.each(rowElement, function() { var currentElement = $(this), ...

Turn off csrf protection when an internal express route is accessed

I have a simple code snippet that implements csrf protection: import csrf from 'csurf'; const csrfProtection = csrf({ cookie: { httpOnly: true, secure: process.env.NODE_ENV === 'production', }, }); app.use(csrfProtection) ...