Adding a tint to a transparent image

Is there a way to tint only the white elements in the navbar when they are clicked, rather than applying the color overlay to the entire image? I have tried different methods but have not been able to achieve this effect. Ideally, I would like the white parts of the image to multiply with the specified color, similar to the multiply function in Photoshop.

.wrap {
  position:relative;
}

.wrap:before {
  content:"";
  position: absolute;
  top:0;
  left:0;
  height:100%;
  width:100%;
  background: rgba(255,0,0,0.5);
  z-index:999;
}
<div>
    <button class="button button-clear" style="margin: 5px;" routerLinkActive="active" [routerLink]="[route]">
        <div class="wrap">
            <img *ngIf="icon!==undefined" [src]=icon>
        </div>
        <a *ngIf="text!==undefined">{{text}}</a>
    </button>
</div>

https://i.sstatic.net/5iXc1.png

Answer №1

Utilize various filters

body {
  background: lightblue;
}

img {
  width: 150px;
}

img:nth-of-type(2) {
  filter: 
  brightness(0.5) 
  sepia(1) 
  saturate(10000%)/* currently red */  ;
  }

img:nth-of-type(3) {
  filter: 
  brightness(0.5) 
  sepia(1) saturate(10000%)/* currently red */
  hue-rotate(120deg)/* now it's green */;
}
<img src="https://9group.co.uk/wp-content/uploads/2017/06/mobile-icon-white.png" alt="">

<img src="https://9group.co.uk/wp-content/uploads/2017/06/mobile-icon-white.png" alt="">

<img src="https://9group.co.uk/wp-content/uploads/2017/06/mobile-icon-white.png" alt="">

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

Generating table columns using *ngFor method

Trying to create a table in Angular and wondering how to generate table columns using something like *ngFor. I currently have two lists: Data: [ 0: data: [ 0: 0 1: 4 2: 4 3: 3 4: 5 5: 1 ] id: 49 label: "Label_1" 1: data:[ 0: 5 1: 0 2: 1 3: 5 4: 0 ...

Adding the BETA symbol to your Bootstrap navbar is simple and can be done by

Is there a way to include a "BETA" symbol at the top of the "Brand Name" on my Navbar, similar to the "TM" symbol? How can this be achieved? ...

The "End Session" button in HTML

Seeking guidance in my journey to learn HTML and CSS, I am attempting to create a dialog box that can be closed with the click of an X button. Despite successfully adding the X button to the dialog box's upper bar, I am facing an issue where clicking ...

Reorganizing Firebase data in Ionic 2

I am currently working on an exciting project to develop an Ionic notes application, where users can easily rearrange items in the list using the reorderArray() function. However, I encountered an issue with Firebase resulting in an error message related t ...

Attempting to place the search bar within the navigation bar

Having trouble positioning a search bar in my nav bar, I'd like it to show on the right side without overlapping any other elements. Tried relative and absolute positioning with no success so far. Any assistance would be greatly appreciated, thank yo ...

Move and rearrange table columns in Angular with input and checkbox options

Is there a way to enable dragging and dropping for table columns that contain input and checkbox fields? I've attempted to do this with cdk-table, but so far I'm only able to drag and drop static columns. Any guidance on how to achieve this would ...

The validator is incorrectly diagnosing the input as 'invalid' when in reality it is not

Currently, I am working on creating a text field that must not be empty and should also not start with a specific set of characters (let's say 'test'). For example, I want testxyz or an empty field to be considered invalid, while anything e ...

On large screens, the Bootstrap 4 navbar will open the dropdown menu when hovered over, while on small screens it will require a click

Recently, I was working on creating a navbar with a dropdown menu that opens when hovered over. After some trial and error, I managed to achieve this functionality using the following jQuery code: $('body').on('mouseenter mouseleave', ...

Tips on transferring component changes from one page to another

I have a select-option control that appears on multiple pages, so I created a single page to contain the select-option and then included that page in other pages. The issue I am facing is that when I use this component on page 1 and update the selected val ...

Trigger Change Detection once Angular Material matDialog is closed

Within my parent component, I have two child components: FilterBookmarksComponent and ManageBookmarksSidebar. The FilterBookmarksComponent features an Angular Material Dropdown that dynamically updates the list of filters below it based on the user's ...

Update the style of a div within an iframe in React

I'm currently developing a project in Next.js and I've added an iframe within a component. The issue I'm facing is that I need to customize the style of a specific div inside the iframe, but I'm having trouble targeting the div with the ...

Placing an absolute div directly at the boundaries of an inline span

In my project, I am working on adding a feature where text can be selected with the help of "handles." These handles have to be positioned either on the left or right side of the inline span. For reference, here is an image: https://i.sstatic.net/U1XGe.jp ...

The label is not displaying the specified font-family in CSS

Below is a snippet of code that I am having trouble with: testing some content Additionally, here is the CSS code for it: label { font-family: "Andale Mono"; } The issue I am facing is that no matter which font style I try to apply, it does not seem to ...

Is it possible to specifically focus on Google Chrome?

Can anyone help me with positioning the update button on www.euroworker.no/order? The button works fine in Firefox and Internet Explorer, but it's not displaying correctly in Chrome or Safari. I've tried targeting Safari and Chrome specifically, ...

What could be the reason for my flex items not shrinking when the browser window size is decreased?

Here is the CSS code for the header component using flexbox: .header { display: flex; flex-direction: row; justify-content: space-between; padding: 15px 20px; background-color: #ffffff; position: sticky; top: 0; z-index: ...

Encountering a "undefined response" issue within an Angular

I am encountering an issue when trying to fetch data from a REST API. Upon logging the response, I am getting an undefined value. How can I resolve this? I have confirmed that the API is sending data by checking my network tab in the developer tool. getPro ...

Tips for handling a function only after the model window has returned a promise in Angular 2

When a button is clicked, three functions are called in sequence within a promise. The first function is responsible for blocking a model window and returning a promise which then resolves the next function. The HTML code snippet is as follows: ...

ngModel not refreshed in ng-pick select directive

Within my code, I am utilizing the ng-select component which is initially set up in the following HTML format. <ng-select id="SelectType" placeholder="Student" [multiple]="true" [items]="students" groupBy="type" [selectableGroup]="false" ...

Eliminating the Scrollbar from Bootstrap 4 DataTable Causes Table Width to Decrease

My tables are causing a horizontal scroll bar to appear when converted to Bootstrap data tables. Adding the "p-3" class to the table's div for padding eliminates the scroll bar but also narrows the table. Is there a solution to removing the scroll b ...

The Child Component encountered difficulties in connecting to the EventEmitter via the service

In the code snippet below, we have the Subscribing Component "pop-list.component.ts" : import { Component, OnInit } from '@angular/core'; import { ChildCommService } from '../child-comm.service'; @Component({ selector: 'app-pop- ...