Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG path as div background [duplicate]

Tags:

html

css

svg

I have an SVG path (as below) that I want to use as a background in a div, does anyone know how to do this, I've searched the web but cant find any simple examples?

<svg xmlns="http://www.w3.org/2000/svg" width="4442" height="720" viewBox="0 0 4442 720">
  <path d="M36,297.64c317.62,0,428,134.58,696,136.74S1160,364,1436,389s431.72-102.09,618-91.36,505.93,73.37,715,72.29,339,72,674,64.45,712.27,157.83,920,174l46,111.14H36Z" transform="translate(0 0)" style="fill-opacity:0.029999999329447746"></path>
</svg>
like image 207
user1419810 Avatar asked Sep 11 '25 07:09

user1419810


1 Answers

Simply use it as background-image then adjust the needed values:

div.back {
  width:600px;
  height:120px;
  background-image:url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="500" height="100" viewBox="0 0 4442 720"><path d="M36,297.64c317.62,0,428,134.58,696,136.74S1160,364,1436,389s431.72-102.09,618-91.36,505.93,73.37,715,72.29,339,72,674,64.45,712.27,157.83,920,174l46,111.14H36Z" ></path></svg>');
  background-size:cover;
  background-color:pink;
}
<div class="back"></div>
like image 135
Temani Afif Avatar answered Sep 12 '25 21:09

Temani Afif