Search code examples
htmlcsspng

HTML png background


Car

I want to use this image (or any other) in a school project but I want those gray and white squares to dissapear and only have the car.

<html>
<head>
  <meta charset="UTF-8">

  <style> body {padding: 0; margin: 0; background-color : #000;}
  
  #div{
   background : url('https://banner2.kisspng.com/20171201/41c/mercedes-benz-png-file-5a21ecfdce9485.7702393815121727978462.jpg') no-repeat;
   background-size : cover;
   height : 500px;
   width : 500px;
  }
  </style>
</head>

<body>

<div id="div">
</div>
</body>
</html>

I couldn't find anything specific about this problem because I don't what is the actual question to ask.


Solution

  • Your file is a jpg, which doesn't support transparency. You need to export your image as PNG in order to get transparency working