how to remove the white image html-css like png? Can we use CSS to delete the white photo background?
.tracking-wider {
content: "";
background-color: rgba(0, 0, 255, 0.5);
width: 100%;
height: 100%;
z-index: 1;
opacity: 1;
transition: opacity .2s;
display: inline-block;
}
.tracking-wider:before {
content: "";
background-color: rgba(0, 0, 255, 0.5);
width: 100%;
height: 100%;
z-index: 1;
opacity: 1;
transition: opacity .2s;
}
css styles your html page, meaning it works on html element. Since your image is in one elemennt you cannot have different styles for this elt. We can imagine having a stack of different elements with the property z-index but it will be awful to code/manage.
The only/best thing you have to do is to recreate your image to remove the background and manage it by directly by css or with a second image/element.
@sr57
How to recreate my image to remove the background?
@kar Open it in an image editor and remove the white background (eraser tool)
@kar How would css know the difference between the white around the image, and the white on the screen?
@Sinnbeck
nice example ... anyway. My previous answer should be 'no exact way'
@sr57 Yeah I completely agree with you. I would never do this with css :)
@Sinnbeck
I changed this code
<div class="tracking-wider">
<img class="w-100 d-inline-block" src="{{ asset('storage/'.$service->image) }}">
</div>
.tracking-wider img {
mix-blend-mode: multiply;
}
I see this demo.
My problem is still not solved. Where is my real photo?
@kar how would I know? First if I already suggested doing it in a image program and explained why. Secondly I don't have access to your image so how could I test it? I gave a link to a page where it kinda works and expected you would test your image there
@Sinnbeck For example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.tracking-wider {
background-color: blue;
width: 200px;
height: 200px;
position: relative;
}
.tracking-wider img {
mix-blend-mode: multiply;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 100%;
}
</style>
</head>
<body>
<div class="tracking-wider">
<img src="https://dkstatics-public.digikala.com/digikala-products/c5c4a0bb88dc312a4c2f6de0b1567ef0da31a2d9_1630140406.jpg" alt="">
</div>
</body>
</html>
@kar try setting the background color to #00ff00 in the link I shared an you will see the same. Aka not possible. Lightgray background only
@Sinnbeck
I changed .
background-color: #D3D3D3;
you could 'crop' the image with object-fit and object-position. but since you will need a different CSS for each image, it's not a solution
@Chaeril no you cannot because the browser can't see the object within the photo
Please sign in or create an account to participate in this conversation.