Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS change d property of <path>

Tags:

I have a generated svg path code, I want to override it with CSS file to change the svg shape. I could override all the properties except 'd':

Here is the generated code (I can't change it directly):

<div id="map_outer" style="position: absolute; left: 3px; z-index: 1;"> <svg height="35" version="1.1" width="35" xmlns="http://www.w3.org/2000/svg" style="overflow: hidden; position: relative;"><desc style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Created with Raphaël 2.1.0</desc> <defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"> </defs> <path fill="#cecece" stroke="#808080" d="M503.7,743.8C694,647.1999999999999,636.6,326.74999999999994,348.1,334.09V205.39L120.00000000000003,400.39L348.1,606.19V474.59000000000003C589,469.09000000000003,578,677.3900000000001,503.70000000000005,743.8900000000001Z" stroke-width="40" stroke-opacity="1" fill-opacity="1" transform="matrix(0.05,0,0,0.05,-1.9,-5.7)" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); stroke-opacity: 1; fill-opacity: 1; cursor: pointer;"> </path> </svg> </div> 

Here is the CSS to override the d value, I get

Unknown property name

in the CSS inspector !!! :

enter image description here

#map_outer svg path{     fill: rgb(255, 204, 0) !important;     d:"M 850 300 C 850 300 350 300 350 300 L 348.1 205.39 L 120 400.39 L 348.1 606.19 L 350 500 C 850 500 850 500 850 500 z" !important;     stroke-width: 0; } 
like image 667
user2997418 Avatar asked Feb 14 '17 13:02

user2997418


People also ask

What is d attribute in path?

The d attribute defines a path to be drawn. A path definition is a list of path commands where each command is composed of a command letter and numbers that represent the command parameters.

Can I use path in CSS?

path() The path() CSS function accepts an SVG path string, and is used in CSS Shapes and CSS Motion Path to enable a shape to be drawn.

What does D mean in HTML?

d is Path Data. The definition of the outline of a shape. Reference : http://www.w3.org/TR/SVG/paths.html#PathData.


1 Answers

You're almost on the right track here, you just need to set the correct value for the property. It's missing path('..'):

#map_outer svg path {     d: path('M 850 300 C 850 300 350 300 350 300 L 348.1 205.39 L 120 400.39 L 348.1 606.19 L 350 500 C 850 500 850 500 850 500 z') !important; } 
like image 166
brendonofficial Avatar answered Sep 29 '22 21:09

brendonofficial