-1

I have one image that image background is white, In my webpage, The background color is #ebf5fc; when I insert the image it's not fit correctly, so what I need is the inserted image should be a transparent with background and the width should be 100%, please help me to fix this issue.

* {
background:#ebf5fc;
}

.shape-images {
    width:100%;
    background: #ebf5fc;
}
<div class="shape-images">
    <img src="https://docs.google.com/uc?export=download&id=1ED93sN3oWFtp9fHkAzTLK8Qp0B9Etv4r" />
</div>
ConnerWithAnE
  • 1,106
  • 10
  • 26
Code cracker
  • 316
  • 1
  • 5
  • 20

2 Answers2

1

If the background of the image is filled with white and not just "transparent" then this is kind of impossible. You cannot use css to alter the background colour of an image. You could alter the image using a magic wand or select tool in Photoshop and then input the image with a transparent background.

https://photopea.com

This is a great option if you do not have access to Photoshop. It's free and can do nearly all of the functions of Photoshop.

ConnerWithAnE
  • 1,106
  • 10
  • 26
1

removing a solid color background from an image in HTML is possible using an SVG filter, which can be applied to HTML content.

i wouldn't recommend you actually use this method, removing the background in GIMP or photoshop or whatever is probably how you should solve it, but it is possible.

.demo_table {
  background-color: lime;
}

.remove_white_bg {
  filter: url(#remove_white);
}
<svg height="0" style="position: absolute">
  <filter id="remove_white">
    <feColorMatrix type="matrix" in="SourceGraphic"
      values="1 0 0 0 0
              0 1 0 0 0
              0 0 1 0 0
             -1 -1 -1 2 0" />
  </filter>
</svg>

<table class="demo_table">
  <tr><th>original image</th><th>same image + filter</th></tr>
  <tr>
    <td><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/01/Adaxial_side._Leaves_of_trees_in_autumn.jpg/136px-Adaxial_side._Leaves_of_trees_in_autumn.jpg" /></td>
    <td><img class="remove_white_bg" src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/01/Adaxial_side._Leaves_of_trees_in_autumn.jpg/136px-Adaxial_side._Leaves_of_trees_in_autumn.jpg" /></td>
  </tr>
</table>

(see here for more info on how <feColorMatrix> works)

amgg
  • 546
  • 4
  • 8