How can I eliminate the blending effect between different layers?

Experimenting with blend modes has led me to create a composite image featuring a shirt and a pocket. Initially, everything seemed fine when I only had the shirtVer and shirtHor layers. I could easily merge them and adjust the colors of the checkered pattern without any issues. However, upon adding the pocket layer and blending them using multiply, the final output ended up combining all four layers, which was not my intended result.

Is there a way to create a distinction in the blending between (shirtVer + shirtHor) and (pocketVer + pocketHor)?

HTML

<span class="img-position shirtVer">
</span>
<span class="img-position shirtHor">
</span>
<span class="img-position pocketVer">
</span>
<span class="img-position pocketHor">
</span>

CSS

.img-position {
    position: absolute;
    top: 200px;
    left: 0px;
    display: block;
    width: 768px;
    height: 768px;
    background-blend-mode: multiply;
    mix-blend-mode: multiply;
}

.shirtHor {
    background-color: red;
    background-image: url('img/shirtHor.png');
    -webkit-mask-image: url('img/shirtHor.png');
}

.shirtVer {
    background-color: blue;
    background-image: url('img/shirtVer.png');
    -webkit-mask-image: url('img/shirtVer.png');
}

.pocketHor {
    background-color: yellow;
    background-image: url('img/pocketHor.png');
    -webkit-mask-image: url('img/pocketHor.png');
}

.pocketVer {
    background-color: blue;
    background-image: url('img/pocketVer.png');
    -webkit-mask-image: url('img/pocketVer.png');
}

The current outcome displays the shirt and pocket blended together as shown in the following image:

https://i.sstatic.net/Ij1aN.png

Answer №1

Thanks to the guidance of a close friend, I was able to find a solution to my problem. I incorporated an additional layer with the base shape and refrained from applying any mix to that layer. Here is the solution:

HTML

<span class="img-position shirtVer mix">
</span>
<span class="img-position shirtHor mix">
</span>
<span class="img-position pocketBase">
</span>
<span class="img-position pocketVer mix">
</span>
<span class="img-position pocketHor mix">
</span>

CSS

.img-position {
    position: absolute;
    top: 200px;
    left: 0px;
    display: block;
    width: 768px;
    height: 768px;
    background-blend-mode: multiply;
}

.mix {
    mix-blend-mode: multiply;
}

.shirtHor {
    background-color: red;
    background-image: url('img/shirtHor.png');
    -webkit-mask-image: url('img/shirtHor.png');
}

.shirtVer {
    background-color: blue;
    background-image: url('img/shirtVer.png');
    -webkit-mask-image: url('img/shirtVer.png');
}

.pocketBase {
    background-image: url('img/pocketFull.png');
    -webkit-mask-image: url('img/pocketFull.png');
}

.pocketHor {
    background-color: yellow;
    background-image: url('img/pocketHor.png');
    -webkit-mask-image: url('img/pocketHor.png');
}

.pocketVer {
    background-color: blue;
    background-image: url('img/pocketVer.png');
    -webkit-mask-image: url('img/pocketVer.png');
}

The end result turned out exactly as planned, see it for yourself:

https://i.sstatic.net/4sTmY.png

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

Creating a responsive card layout in Bootstrap 4 that utilizes the vertical space of the viewport with a scrollbar

We are working on a page that has specific requirements: The page should not have a scroll bar. The card must expand vertically to fill the remaining space, even if there is no content in the card-body. We need a scroll bar for the card-body only when the ...

Build desktop-style applications using a unique user interface library and integrated development environment designed specifically for HTML, JavaScript

I am looking to create a desktop application using HTML, JavaScript, and AJAX for the purpose of making it available on multiple platforms. I was wondering if there is a UI library and web IDE similar to WebOS Enyo that I can use to build my HTML/AJAX app? ...

The mismatch between the number of elements in the type definition string and the number of bind variables in the mysqli_stmt::bind_param() function prevents the UPDATE operation from

I am encountering an issue with submitting or updating this data. The data does not seem to update when I try. Here is the code causing the problem: if(isset($_GET['newsid'])){ if(isset($_POST['submit'])){ $sql = $connect- ...

Extracting targeted information from an HTML page using Python: A step-by-step guide

I'm a beginner in python and I need to scrape information from an HTML text file using python 2.7. The example below shows the structure of one firm's data in the HTML file. The same structure is used for all other firms as well, with each firm ...

Is there a way to access a private table in Google BigQuery using a Python script without needing an authorization token?

Is there a way to submit a query into Google's BigQuery and retrieve results from a python script without needing an authorization code for private tables? The python script is accessed through a user-friendly webpage, so manual authorization code han ...

tag-swapping function

I have a specific HTML code paragraph that I am working with: <p id=tag1> html statements before click </p> My goal is to create a function that will split the paragraph into two separate paragraphs like so : <p id=tag1> html statement ...

How to achieve a Dropbox-inspired footer effect using CSS?

Take a look at dropbox's website here: Have you noticed how the footer with "Learn more" remains fixed at the bottom regardless of window resizing until you click or scroll down? position: absolute; bottom: 50px; left: 0; width: 100%; text-align: ce ...

What is the best way to obtain the file's pathway?

:image => StorageRoom::Image.new_with_filename(path) When trying to retrieve the image path, I initially specified it manually and it worked fine. However, after deploying to Heroku, an error message 'Load Error - No such file present' is dis ...

"Troubleshooting a Responsive Design Problem: Horizontal Scroll Bar Appears on Low Res

My website is experiencing an odd issue with responsiveness. When viewed on desktop resolution in Chrome, there is no horizontal scroll. However, when I resize the browser to lower resolutions (400px width and less), the horizontal scroll appears. It see ...

Troubleshooting CSS compatibility issues in Firefox browser (or HTML rendering as plain text)

In a unique web page comparing two photos, the clicked one changes, but there's an issue in Firefox where HTML displays as text and links don't work. CODE:- * { box-sizing: border-box; } html { height: 100%; } body { height: 100%; mar ...

The utilization of local storage within Backgridjs

I am creating an app using Backbone.js (Marionette Framework) along with additional functionalities like Backgrid, Backbone local storage, Backbone Radio, epoxy, and Backbone relational model. Encountered Problem: An issue arises when utilizing the local ...

How can I prevent an image from scrolling on a webpage?

I am seeking a way to prevent an image from scrolling along with the rest of the page. I want the image to occupy a specific percentage of width, while allowing the browser to determine the appropriate height for display. The image's height should als ...

Why won't my Twitter Bootstrap navigation bar apply the styles?

I am currently working on a Rails app (4.0) and have incorporated Bootstrap 3 into my project. Both bootstrap.css and bootstrap-theme.css are stored in the stylesheets directory, while bootstrap.js is located in the javascripts directory. Most of the Boots ...

Include a horizontal line divider between each row of items that wrap to the next line

I am utilizing CSS flexbox to arrange a variable number of items in rows, wrapping around to additional rows as necessary. My query is, can a horizontal line be inserted between each of the rows? Here you can find a basic example of what I am working on. ...

Achieving a sleek line effect with a gradient border

Is there a way to make the gradient border transition between two colors look like a straight line? Additionally, is it possible to have the line start in the bottom left corner instead of the middle of the right side of the button? The current CSS code I ...

Adjust the size of a ul element to fit within a div

I am struggling with getting a ul element with 2 li items inside to perfectly fit a parent div. I want the li items to take up 100% of the height of the div and 50% of the width each. <div id='menu-wrapper'> <ul id='menu-list&a ...

Determine the aspect ratio with a constant adjustment using CSS/SCSS

I am trying to adjust the aspect ratio of a responsive div to create a square shape with an offset. I want the height to be equal to the width plus the specified offset. Here is an example of what I am attempting: .div { width: 100%; aspect-ratio: 1 / ...

Developing a jQuery Plugin to Generate an Interactive Dropdown Menu

I have a task to dynamically create a select list in which users can add options after the select list has been created. Check out my code snippet below: <script type="text/html" id="select_field"> <div class='row& ...

Resizing and uploading multiple images with accompanying descriptions

I am in need of a solution for uploading multiple images along with descriptions. Users will be uploading 1-10 large-sized images from cameras, so it would be ideal if the images could be resized before the upload. My requirements are: Compatibility wit ...

Please reset the form fields after the most recent edit

I've created a form that includes multiple select elements. When an option is selected, it activates the next select element and updates it with values using Ajax and PHP. However, I'm facing an issue where changing a previous option only resets ...