Changing the Color of a PNG Image Using only 1-line CSS in WordPress

Ivan Oung

Result

Use nothing but CSS to change the color of a PNG image.

Problem

Targeted Style
Current Style

The challenge would be easier if I can just use toosl like Photoshop to change the source image into white.

However, all pages have a top navigation bar with a white background, and WordPress only accept one logo at a time, so changing the color of the logo with a photo editing tools would not be a feasible idea.

Which left me with nothing else but CSS.

Solution

After a bit of searching, CSS Filter seems to be the best way to go.

Definition from MDN web docs
.header-image {
        filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(1%)
            hue-rotate(149deg) brightness(103%) contrast(101%);
    }

I also used this color filter generator to come up with the code that I need, which in my case is just pure white.

After applying CSS Filter

Perfect result!

Navigation Menu

Share

Stay In Touch!

I'll only send the good stuff, no spam, no bs, I promise!

More Readings

10 Reasons Why WordPress is the Ultimate Choice for Your Blogging Journey

Blogging has become a popular way for individuals and businesses to share their ideas, opinions, and experiences with the world. It allows people to connect with others who have similar ... Read more

Maximizing Your Website’s Potential with a CMS: A Beginner’s Guide

Content Management Systems (CMS) have become an essential tool in website management. With the increasing complexity of websites and the need for frequent updates, CMS provides a user-friendly interface that ... Read more

Unleashing the Power of Development: How to Foster Growth and Progress

Development is a crucial aspect of growth and progress in any field or industry. It involves a continuous process of improvement and innovation to achieve better results. Whether it’s in ... Read more

A WordPress Developer Who You Can Trust.

I always build my relationships with my clients based on trust. I want to see you grow as much as I myself. Let's work together to grow your business.

Get A Free Quote
Share to...