PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, September 30, 2022

[FIXED] How to apply half a color filter to image in CSS?

 September 30, 2022     bootstrap-5, css, filter, html, twitter-bootstrap     No comments   

Issue

I'm currently coding a new website for my business as our current one is outdated, using the mock-up our graphics designer created for us. I'm a little stuck on how I go about adding a filter to the image, like the following example, and wondered if someone on here could help me? Google seems to be of no use, sadly.

Example of filter I mean


Solution

You can overlay a semi-transparent gradient over the element.

.filter {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, #001f3f, transparent);
}
.wrapper {
  position: relative;
  display: inline-block;
}
<div class="wrapper">
  <img class="image" src="https://i.imgur.com/5VSUqlS.png" width="300px" />
  <div class="filter"></div>
</div>



Answered By - kess
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing