Troubleshooting the malfunctioning CSS Blend Mode

I'm eager to experiment with the CSS blend mode property, but I'm running into an issue where nothing seems to change when I apply the rules.

Could there be something wrong in my implementation? I've set the isolation rule for the parent and used mix-blend-mode on the specific element I want to manipulate.

Below is the code snippet along with a link to a helpful CodePen example.

.day-old {
    position: relative;
    isolation: isolate;
}

.day-old:before {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 99.9%;
    height: 38px;
    content: "";
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

.day-old .day-row {
    opacity: 0.5;
}

.day-row {
    display: -ms-flexbox;
    display: flex;
    width: 100%;
}

.day {
    background: #f5f5f5;
    margin: 0;
}

.day span {
    display: block;
    padding: 10px;
}

.availability {
    display: flex;
    width: 100%;
    text-align: center;
     margin: 0;
}

.slot {
    display: block;
    padding: 10px 0;
    color: #3c763d;
    background: #dff0d8;
    width: 100%;
    box-shadow: -1px 0px 0px #c7d9b9 inset, 0px -1px 0px #c7d9b9 inset;
    mix-blend-mode: screen;
}
<div class="day-old">
    <div class="day-row">
     <p class="inner day"><span><strong>13/04</strong></span></p>
     <p class="availability">
       <span class="slot">
         <strong>2500</strong>                                              </span>
     </p>
  </div>
</div>
                     

Thank you!

Answer №1

Your code is operational, however, the desired effects may not be readily apparent due to your chosen color scheme. For optimal results with the mix-blend-mode property, consider incorporating a background image. Try combining the background image with a background color property, like in the example below:

<div class=”container”>
  <h1 class=”header-text”>Hello world</h1>
</div>

.container {
  background-image: url(‘image.png’);
  background-size: cover;
}

.header-text {
  font-size: 7rem;
  text-transform: uppercase;
  color: #fff;
  text-align: center;
  background-color: darkcyan;
  mix-blend-mode: multiply;
}

For further clarification on this property, you can also refer to an informative article here.

Answer №2

When working with background images, blend modes are commonly employed to achieve various effects. This technique is reminiscent of using blend modes in software like Photoshop, where you can overlay a layer with a solid color on top of an image and then adjust the blend mode to 'screen,' 'darken,' or other options.

For instance:

.bar {
  background-image: url(forest.jpg);
  background-color: blue;
  background-blend-mode: lighten;
}

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

PHP script, creating a public function that manipulates an array while also incorporating CSS styles

Within a public function, I have the following PHP: [ 'type' => 'text', 'desc' => $this->l('some information'), ] Using this code will show the text "some information" on a webpage. Is there a way ...

"Pressing the 'back' button on your browser takes

Is there a way to navigate back to the main page by clicking on an image? After selecting First, Picture1 will be shown. How can I go back to the selection page for further choices? <a href="picture1.jpg"> <h3>First</h3></a> <a ...

The functionality of my website is not optimized for viewing on iPhones

While designing a responsive website that looks great on most devices, I noticed some issues with iPhones. The layout breaks in two specific ways on these devices. View Galaxy Screenshot View Sony Screenshot The menu doesn't scale properly on iPho ...

Ways to modify the header color of a card by utilizing a Select element in Javascript, while ensuring that it does not impact other cards

I am facing an issue with multiple cards, each containing a Select element. When a user selects an option from the Select element, the card header changes color, but it also affects all other card headers. How can I separate them? [data-background-co ...

What is the best way to center-align elements?

I have a couple of inquiries. First off, I'm facing an issue with centering everything within a form while aligning the text to the left side of the fields. I've attempted using justify-center and align-items within the "container" class and th ...

MathJax only functions properly on Firefox Browser; for all other browsers, it fails to work as intended

I have integrated MathJax into a website that I designed. Everything works perfectly fine on Firefox, but there seems to be an issue with MathJax input when I try to open the site on Opera, for example. Here is the code snippet that is causing problems on ...

Show HTML code inside a text box

I have a text box that I populate with data from a Json response like this: <div class="gadget-body" style="height:100px"> <label>{{ textData}}</label> </div> Now, the Json response contains HTML code with <p> and < ...

Guide on excluding the first row when referencing all rows with CSS

My div container is hosting a table and I have a requirement to set the height of all rows, except the first one, to a specific value. Additionally, I need to adjust the text size in each column excluding the first row: This snippet shows my current html: ...

In mobile browsers, the text within the <pre> tags appears extremely small. How can I adjust the font

My issue is with preformatted text that displays correctly on desktop browsers but appears very small on mobile devices in comparison to regular text. Adjusting the size using ems or percent causes it to be too large on desktop screens. Despite searching e ...

Encountering an undefined error while attempting to retrieve an object from an array by index in Angular

Once the page is loaded, it retrieves data on countries from my rest api. When a user selects a country, it then loads the corresponding cities for that country. Everything is functioning properly up to this point, however, upon opening the page, the city ...

Creating a custom breakpoint in Bootstrap for adding unique CSS styles

Consider this scenario <div class="col-md-my"> </div> .xx { color: black; } .yy { color: red; } Similar to how Bootstrap adjusts width at different breakpoints. Create a new class called col-md-my When the width exceeds the ...

Setting up aliases for "HTML import" paths - a step-by-step guide

Recently, I've been experimenting with Web Components and Polymer, creating a basic single-page application. Within my project, I have various custom components. My HTML imports are structured like this: <link rel="import" href="../core-icon/core ...

Is there a way to retrieve both the name of the players and the information within the players' profiles?

Just dipping my toes into the world of Javascript and jQuery while attempting to create an in-game scoreboard for Rocket League, I've hit a bit of a roadblock. Here's the console log output of data from the game: I'm particularly intereste ...

clicking the anchor will toggle the div

Here is the HTML code that I am working with: <? while($arr as $data) { ?> <td> <div> <a href="javascript:void(0)" class="status <?= $data['SUGGESTION_CD'] ?>"> <img src="images/activate.gif" /> &l ...

Troubleshooting issue: Angular not resolving controller dependency in nested route when used with requirejs

When the routes are multiple levels, such as http://www.example.com/profile/view, the RequireJS is failing to resolve dependencies properly. However, if the route is just http://www.example.com/view, the controller dependency is resolved correctly. Below ...

The header logo will have an absolute position to overlay the navigation menu when the screen is resized

I am currently working on a website layout that involves using position: absolute for the logo to overlay another div below it, purely for stylistic reasons. While I have achieved this effect, it doesn't translate well into responsive web design. When ...

Prevent automatic submission of forms when selecting attributes in HTML forms using AngularJS

I need to create a form where users can select their branch of study. Here is the form I have designed- <form method="post" [formGroup]="formData" (click)="dataSubmit()" > <div class="form-group"> <label for="branch">Selec ...

I'm attempting to align my text at the center of my tab navigation but it doesn't seem to be working

I'm struggling with centering the text within the li tags in my tabbed navigation bar. I don't want to add padding to the top of the text because I want the entire tab to be clickable. Any advice on how to achieve this? Also, how can I make the l ...

Surrounding the text with background color

My H1 text is in a div that spans multiple lines due to the fixed width of the div. I am looking to set the background color to only appear behind the actual text of the H1, without extending into empty space at the end of each line. In addition, I also n ...

Creating Hbbtv applications with the help of a Firefox Addon

My curiosity lies in creating hbbtv apps and I am eager to learn how to run and test a complete hbbtv application package, specifically a videoplayer with multiple html pages, utilizing the FireHBBTV plugin on Firefox. Despite my extensive search efforts ...