Arrow Box with CSS - css

How can I make this box in CSS?
I've seen a few tutorials that teach how to create boxes with arrows, however, in my case, none of those tutorials are suitable.

I created your element with the surrounding 1px border. I'm using one <div> element and taking advantage of the :before and :after pseudo-elements (browser-support). The main rectangle has a regular 1px border, but the triangle elements are essentially 2 triangles, one darker than the other.
The lighter triangle sits on top of the darker triangle, which has the effect of hiding it, and is shifted slightly to the left to show the darker triangle underneath. The resulting illusion is a 1px dark border on the triangle itself.
Here's a question that asks a similar question:
How can I create a "tooltip tail" using pure CSS?
One of the answers actually has a great explanation of how one can achieve this triangle effect:
https://stackoverflow.com/a/5623150/196921
Also, this is an excellent reference for all the fancy things you can do with borders (thanks to PSCoder):
http://css-tricks.com/examples/ShapesOfCSS/
... and here's a sweet css generator (thanks to David Taiaroa):
http://cssarrowplease.com/
Anyway, here's the corresponding code:
#arrow {
width: 128px;
height: 100px;
background-color: #ccc;
border: 1px solid #999;
position: relative;
}
#arrow:after {
content: '';
position: absolute;
top: 0px;
left: 128px;
width: 0;
height: 0;
border: 50px solid transparent;
border-left: 12px solid #ccc;
}
#arrow:before {
content: '';
position: absolute;
top: 0px;
left: 129px;
width: 0;
height: 0;
border: 50px solid transparent;
border-left: 12px solid #999;
}
<div id="arrow"></div>

Here is the solution I created
There are 2 simple ways to do this. The first, less efficient way is to have 2 elements. I take advantage of the :after pseudo element. I used position:absolute on the :after for 2 reasons.
You can place the element where you need to
It prevents the end of the triangle from being cut off
The key to creating the triangle is using the border property. You have 2 borders with the color of transparent set. These 2 borders are opposite of the direction you want to go. So if you want to make a right triangle, then use top and bottom. What gives the arrow it's shape is the last border. It also goes in the opposite direction. So for a right triangle, you would use border-left with a color. To get this to be the proper height, you must do half of the height of the box you want to place it on

SVG is the recommended way to create such shapes. It offers simplicity and scale-ability.
We can use SVG's polygon or path element to create a shape like above and stroke / fill it with some solid color, gradient or a pattern.
Only one attribute points is used to define shapes in polygon element. This attribute consists of a list of points. Each point must have 2 numbers, an x coordinate and a y coordinate. A straight line is drawn automatically from the last point to the starting point to close the shape.
Below is the necessary code to create this shape:
<polygon points="10,12 265,10 285,93 265,184 10,184"
stroke="#333"
stroke-width="2"
fill="#eee" />
Below is a brief description of the above code:
points attribute defines the structure of the shape.
stroke attribute defines the color for the outline / border.
stroke-width defines the thickness of the outline / border.
fill attribute defines the color for the interior shape to be filled.
Output Image:
Working Example:
body {
background: #b6cdc7 url("https://www.hdwallpapers.net/previews/hot-air-balloon-over-the-mountain-987.jpg") no-repeat;
background-position: center bottom;
background-size: cover;
margin: 0;
}
.box {
justify-content: center;
align-items: center;
height: 100vh;
display: flex;
}
<div class="box">
<svg width="300" height="200" viewBox="0 0 300 200">
<polygon points="10,12 265,10 285,93 265,184 10,184" stroke="#333" stroke-width="2" fill="#eee" />
</svg>
</div>
This shape can be filled with gradient or pattern as well.
Working Example:
body {
background: #b6cdc7 url("https://www.hdwallpapers.net/previews/hot-air-balloon-over-the-mountain-987.jpg") no-repeat;
background-position: center bottom;
background-size: cover;
margin: 0;
}
.box {
justify-content: center;
align-items: center;
height: 100vh;
display: flex;
}
<div class="box">
<svg width="300" height="200" viewBox="0 0 300 200">
<defs>
<linearGradient id="grad">
<stop offset="0" stop-color="#11a798" />
<stop offset="1" stop-color="#23645d" />
</linearGradient>
</defs>
<polygon id="shape" points="10,12 265,10 285,93 265,184 10,184" stroke="#333" stroke-width="2" fill="url(#grad)" />
</svg>
</div>
We can apply shadow on this shape using SVG's filters.
Working Example:
body {
background: #b6cdc7 url("https://www.hdwallpapers.net/previews/hot-air-balloon-over-the-mountain-987.jpg") no-repeat;
background-position: center bottom;
background-size: cover;
margin: 0;
}
.box {
justify-content: center;
align-items: center;
height: 100vh;
display: flex;
}
<div class="box">
<svg width="300" height="200" viewBox="0 0 300 200">
<defs>
<linearGradient id="grad">
<stop offset="0" stop-color="#11a798" />
<stop offset="1" stop-color="#23645d" />
</linearGradient>
<filter id="shadow">
<feGaussianBlur in="SourceAlpha" stdDeviation="4" />
<feMerge>
<feMergeNode />
<feMergeNode in="SourceGraphic" />
</feMerge>
</filter>
</defs>
<polygon id="shape" points="10,12 265,10 285,93 265,184 10,184" stroke="#333" stroke-width="2" fill="url(#grad)" filter="url(#shadow)" />
</svg>
</div>

Related

SVG ClipPath: Why does applying the clip path to a DIV have different results to an IMAGE?

I need to create a set of 3 triangles that each have content in them (images, copy, etc).
I have setup this Pen to show roughly what I'm trying to achieve: https://codepen.io/andystent/pen/OJyNdmB
And here is an image for quick reference:
In this example the "Top" and "Left" triangles are IMAGES with the clip-path applied and displaying perfectly.
The "Right" triangle (with the red background) is a DIV with the clip-path applied but the proportions are wrong.
It should look like a mirrored version of the "Left" triangle.
When I apply it to an image it is perfect but when I apply to the div it is not. What is the best way to do this?
I am new to SVG so it is extremely likely that I am not doing this correctly. I have looked at numerous posts and the method I have tried is from a few of those but without success... so now I'm reaching out to you geniuses...
Here's the HTML and CSS for the red "Right" triangle with the clip applied to the DIV in the CSS:
#right-wrapper {
position: absolute;
width: 50%;
height: 100%;
right: 0;
padding: 40px 20px;
box-sizing: border-box;
}
#right-content-div {
background-color: red;
height: 100%;
width: 100%;
position: absolute;
top: 0;
right: 0;
clip-path: url(#clip-path-right);
-webkit-clip-path: url(#clip-path-right);
display: flex;
justify-content: center;
align-items: center;
}
<div id="right-wrapper">
<svg width="100%" height="100%" viewBox="0 0 1220 1214" preserveAspectRatio="none">
<defs>
<clipPath id="clip-path-right">
<path d="M1232,1212.58943 L1232,4.82844551 C1232,3.17159126 1230.65685,1.82844551 1229,1.82844551 C1228.53907,1.82844551 1228.08435,1.93465364 1227.67111,2.13882722 L18.145562,599.743544 C13.1941115,602.189966 11.1633848,608.187127 13.6098071,613.138577 C14.582638,615.107544 16.1765951,616.701501 18.145562,617.674332 L1227.67111,1215.27905 C1229.15654,1216.01298 1230.95569,1215.40376 1231.68962,1213.91832 C1231.89379,1213.50508 1232,1213.05036 1232,1212.58943 Z" id="path-1">
</path>
</clipPath>
</defs>
<div id="right-content-div" preserveAspectRatio="none">
<h1>test heading</h1>
</div>
<!-- <image clip-path="url(#clip-path-right)" height="100%" width="100%" preserveAspectRatio="none" xlink:href="https://www.w3schools.com/css/klematis_big.jpg" /> -->
</svg>
</div>
----- UPDATE: -----
As suggested in the comments, I have created a simplified Pen that gets to the heart of what I'm trying to achieve and the embedded HTML and CSS is below.
Essentially I am trying to get the red <div> to be clipped exactly like the <image>.
https://codepen.io/andystent/pen/RwWRjLd
#right-content-div {
background-color: red;
height: 100%;
width: 100%;
position: absolute;
top: 0;
clip-path: url(#clip-path-right);
-webkit-clip-path: url(#clip-path-right);
}
<svg width="20%" height="20%" viewBox="0 0 1220 1214">
<defs>
<clipPath id="clip-path-right">
<path d="M1232,1212.58943 L1232,4.82844551 C1232,3.17159126 1230.65685,1.82844551 1229,1.82844551 C1228.53907,1.82844551 1228.08435,1.93465364 1227.67111,2.13882722 L18.145562,599.743544 C13.1941115,602.189966 11.1633848,608.187127 13.6098071,613.138577 C14.582638,615.107544 16.1765951,616.701501 18.145562,617.674332 L1227.67111,1215.27905 C1229.15654,1216.01298 1230.95569,1215.40376 1231.68962,1213.91832 C1231.89379,1213.50508 1232,1213.05036 1232,1212.58943 Z" id="path-1">
</path>
</clipPath>
</defs>
<image clip-path="url(#clip-path-right)" height="100%" width="100%" preserveAspectRatio="none" xlink:href="https://www.w3schools.com/css/klematis_big.jpg" />
</svg>
<div id="right-content-div" preserveAspectRatio="none">
<h1>test heading</h1>
</div>
Here is an idea where I will be using mask instead of clip-path. The main trick to correctly set the viewBox (you already have it in your code) add preserveAspectRatio="none" then have a mask size of 100% 100%
.box {
width:200px;
height:200px;
display:inline-block;
background:red;
}
.mask {
-webkit-mask:url('data:image/svg+xml;utf8,<svg preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1220 1214"> <path d="M1232,1212.58943 L1232,4.82844551 C1232,3.17159126 1230.65685,1.82844551 1229,1.82844551 C1228.53907,1.82844551 1228.08435,1.93465364 1227.67111,2.13882722 L18.145562,599.743544 C13.1941115,602.189966 11.1633848,608.187127 13.6098071,613.138577 C14.582638,615.107544 16.1765951,616.701501 18.145562,617.674332 L1227.67111,1215.27905 C1229.15654,1216.01298 1230.95569,1215.40376 1231.68962,1213.91832 C1231.89379,1213.50508 1232,1213.05036 1232,1212.58943 Z" /> </svg>') 0 0/100% 100%;
mask:url('data:image/svg+xml;utf8,<svg preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1220 1214"> <path d="M1232,1212.58943 L1232,4.82844551 C1232,3.17159126 1230.65685,1.82844551 1229,1.82844551 C1228.53907,1.82844551 1228.08435,1.93465364 1227.67111,2.13882722 L18.145562,599.743544 C13.1941115,602.189966 11.1633848,608.187127 13.6098071,613.138577 C14.582638,615.107544 16.1765951,616.701501 18.145562,617.674332 L1227.67111,1215.27905 C1229.15654,1216.01298 1230.95569,1215.40376 1231.68962,1213.91832 C1231.89379,1213.50508 1232,1213.05036 1232,1212.58943 Z" /> </svg>') 0 0/100% 100%;
}
<div class="box mask"></div>
<div class="box mask" style="width:300px;"></div>
<div class="box mask" style="height:300px;"></div>
<img src="https://i.picsum.photos/id/1074/200/200.jpg" class="mask">

How to do radial line gradient around an image and set the % of it? CSS or SVG or anything can solve the problem

I need to develop the next style:
The gradient around the image has diferents colors and can be uncompleted.
How can I do that and set the % of it?
For people that ask for code:
body {
height: 100vh;
margin: 0;
display: grid;
place-items: center;
background: #222;
}
.module-border-wrap {
max-width: 250px;
padding: 1rem;
position: relative;
background: linear-gradient(to right, red, purple);
padding: 3px;
}
.module {
background: #222;
color: white;
padding: 2rem;
}
I believe you'll need to use SVGs. Here is a gradient you can apply to a path. You can use stroke-dasharray and stroke-offset to get the semi circle as well.
<svg height="150" width="150">
<defs>
<radialGradient id="grad1" cx="80%" cy="20%" r="100%" fx="100%" fy="50%">
<stop offset="0%" style="stop-color:rgb(0,0,255);stop-opacity:1" />
<stop offset="100%" style="stop-color:rgb(0,200,255);stop-opacity:1" />
</radialGradient>
</defs>
<ellipse cx="100" cy="100" rx="30" ry="30" stroke="url(#grad1)" stroke-width="10" fill="none" stroke-linecap="round" stroke-dasharray="1000" stroke-dashoffset="840"/>
</svg
The stroke-dashoffset="" is the number you can adjust to increase or decrease the size of the circle. This works because you are creating a dashed line, that has very far apart dashes, so it is only showing part of one dash. If you offset that dash you can move it along the path.

Use part of CSS-Sprite as repeated background image

I have a div with a width and height of approximately 300px each. The background of this div should be filled repeatedly with a smaller image of 8px width and 8px height. This smaller image is embedded into a larger sprite image. How can I only use this 8x8 pixel tile to pave the background?
What I've tried so far:
.world {
width: 300px;
height: 300px;
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAIAAABvFaqvAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4wcYFjsX3EPV0QAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAxklEQVQ4y+2UsQ3CMBBF/0VImYDKFWNQZB28AwOwQ7KOC8agomKCVJ8ituU7GwkhVxFXWT+nF8nvy0JSRFAMye0wqRghxrheTmV+Wx4A9G7BmlpfAi0lswZ0mj2DsiNjLbBx09lRw1oN+m0OAKB7hIQWvFSM43ZY5V7mI88AhB+KZCiZZSiZ9e/RN6BaP1k6MtY2Ry1rPXv01D1yET3qR2ZF+qXX+zMBDJaSuGP1VMXEV/te9q6/G8hV+h2VI2NtrvZn9uzRGzl9Uzsn2uDrAAAAAElFTkSuQmCC') 0 -16px repeat;
}
<div class="world"></div>
In this example code, the shritesheet has a width and height of 24px each. It contains 9 differently coloured points, each of which has a diameter of 7px.
I want that only one single point is used repeatedly as background for the div. However, in this code, the whole picture is repeated instead beginning at the third row of points.
Note, this exemplary spritesheet is only an example. The actual spritesheet is a little more complicated. Replacing the spritesheet
with CSS code is not a solution.
One idea is to consider SVG as background. The trick is to make the image inside the SVG and rely on viewbox to cut the image and show only the needed part then make the whole SVG a pattern for your background.
Simply edit the viewBox to select the pattern you want (x y 8 8 where x,y are equal to [0,8,16])
.box {
width: 100px;
height: 100px;
display:inline-block;
}
.one {
background: url('data:image/svg+xml;utf8,<svg viewBox="16 0 8 8" width="8" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAIAAABvFaqvAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4wcYFjsX3EPV0QAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAxklEQVQ4y+2UsQ3CMBBF/0VImYDKFWNQZB28AwOwQ7KOC8agomKCVJ8ituU7GwkhVxFXWT+nF8nvy0JSRFAMye0wqRghxrheTmV+Wx4A9G7BmlpfAi0lswZ0mj2DsiNjLbBx09lRw1oN+m0OAKB7hIQWvFSM43ZY5V7mI88AhB+KZCiZZSiZ9e/RN6BaP1k6MtY2Ry1rPXv01D1yET3qR2ZF+qXX+zMBDJaSuGP1VMXEV/te9q6/G8hV+h2VI2NtrvZn9uzRGzl9Uzsn2uDrAAAAAElFTkSuQmCC" x="0" y="0" height="24" width="24" /></svg>') repeat;
}
.two {
background: url('data:image/svg+xml;utf8,<svg viewBox="16 8 8 8" width="8" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAIAAABvFaqvAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4wcYFjsX3EPV0QAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAxklEQVQ4y+2UsQ3CMBBF/0VImYDKFWNQZB28AwOwQ7KOC8agomKCVJ8ituU7GwkhVxFXWT+nF8nvy0JSRFAMye0wqRghxrheTmV+Wx4A9G7BmlpfAi0lswZ0mj2DsiNjLbBx09lRw1oN+m0OAKB7hIQWvFSM43ZY5V7mI88AhB+KZCiZZSiZ9e/RN6BaP1k6MtY2Ry1rPXv01D1yET3qR2ZF+qXX+zMBDJaSuGP1VMXEV/te9q6/G8hV+h2VI2NtrvZn9uzRGzl9Uzsn2uDrAAAAAElFTkSuQmCC" x="0" y="0" height="24" width="24" /></svg>') repeat;
}
.three {
background: url('data:image/svg+xml;utf8,<svg viewBox="8 0 8 8" width="8" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAIAAABvFaqvAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4wcYFjsX3EPV0QAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAxklEQVQ4y+2UsQ3CMBBF/0VImYDKFWNQZB28AwOwQ7KOC8agomKCVJ8ituU7GwkhVxFXWT+nF8nvy0JSRFAMye0wqRghxrheTmV+Wx4A9G7BmlpfAi0lswZ0mj2DsiNjLbBx09lRw1oN+m0OAKB7hIQWvFSM43ZY5V7mI88AhB+KZCiZZSiZ9e/RN6BaP1k6MtY2Ry1rPXv01D1yET3qR2ZF+qXX+zMBDJaSuGP1VMXEV/te9q6/G8hV+h2VI2NtrvZn9uzRGzl9Uzsn2uDrAAAAAElFTkSuQmCC" x="0" y="0" height="24" width="24" /></svg>') repeat;
}
<div class="box one"></div>
<div class="box two"></div>
<div class="box three"></div>

Transparent font on transparent background

I am currently working on a scrollbar which looks just like this. If this text is to long for you just skip to the example!
There will be arrows at the left and right side to scroll either left or right. The color of the scrollbar is not grey as it seems but rgba(0,0,0,0.6). So its a transparent black, which will be used in front of images.
Now I want the last few letters in the line to fade out like in this example. To accomplish that I am using a div overlay with:
background-image: linear-gradient(to right, rgba(255,255,255,0), black)
But if I would do that with a transparent scrollmenu, it would mess up the background-color of the scrollmenu (if you don´t know what I mean look here).
So I found a solution by combining two divs with linear-gradients on the very right, which, if you lay them over each other, create exactly the background color of the scrollmenu. One of these lays behind the font, one of them overlays the font. That way I can achieve some transparency on the font. Here is an example for you guys:
#rightPart, #leftPart{
width:200px; height:50px;
position:absolute; top:0;left:0;
color: white;
}
#rightPart{
z-index:-1;
background:linear-gradient( to right, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
}
#leftPart{
background:linear-gradient( to left, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
}
<div id="rightPart"> Slight Transparency effect on this </div>
<div id="leftPart"></div>
The problem is that the transparency effect is limited to the background transparency of 0.5. Therefore the transparency effect can´t get as strong as I want it to be.
Now I am asking for a solution, with which I could achieve a stronger transparency effect. I would appreciate your suggestions.
Please remember that I can´t just make a specific word in the end transparent, since there is always a different word in the end of the scrollbar! Consequently I would need to make the font itself in a specific area transparent. And I personally don´t know how to do that (especially if it is supposed to work on all of the newest browser versions - including IE9+).
<svg> filters are just what your looking for.
IE9 here to ruin your day CAN I USE IT?
Now to adjust the filter simply change the offset of the stop elements inside the linearGradiant.
offset to determine where the effect takes place
stop-color and stop-opacity to determine what the effect should be
example:
<br>
<svg height="40" width="200" viewbox="0 0 100 20" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="endfade" x1="0%" y1="0%" x2="100%" y2="0">
<stop offset="50%" stop-opacity="1" />
<stop offset="90%" stop-opacity="0" />
</linearGradient>
</defs>
<text id="spesial" fill="url(#endfade)" x="0" y="15">Your text here</text>
</svg>
<br>Color?
<br>
<svg height="40" width="200" viewbox="0 0 100 20" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="pinkblue" x1="0%" y1="0%" x2="100%" y2="0">
<stop offset="25%" stop-opacity="1" stop-color="pink" />
<stop offset="50%" stop-opacity="1" stop-color="aqua" />
<stop offset="90%" stop-opacity="0" stop-color="aqua" />
</linearGradient>
</defs>
<text id="spesial" fill="url(#pinkblue)" x="0" y="15">Your text here</text>
</svg>
Well, I can not offer a solution with full browser support.
But since there isn't any other answer, may be it can be useful
First, let's create a base div that will hold the semitransparent color.
Above it, let's set a div with the text. overlayed by a gradient from transparent to gray. this makes the right side of the div fully gray.
The trick is to set for this div a mix-blend-mode of hard-light. This makes gray behave as transparent, keeping black as black
#base {
left: 0px;
width: 200px;
height: 50px;
position: relative;
background: rgba(0,0,0,0.5);
}
#text {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
mix-blend-mode: hard-light;
}
#text:after {
content: "";
position: absolute;
left: 0px;
top: 0px;
height: 100%;
width: 100%;
background: linear-gradient(90deg, transparent 30%, gray 80%);
}
#base:nth-child(2) {
background: rgba(0,0,0,0.25);
}
#base:nth-child(3) {
background: rgba(0,0,0,0.125);
}
<div id="base">
<div id="text"> Slight Transpareny effect on this </div>
</div>
<div id="base">
<div id="text"> Slight Transpareny effect on this </div>
</div>
<div id="base">
<div id="text"> Slight Transpareny effect on this </div>
</div>

Create intersection of lines and circle using SVG and CSS

I am using google maps for interactive map. There is a limiatation the markers will always be a circle. I need circle along with intersection of 2 lines as shown below.
I dont have access to anything except CSS. Would it be possible to add CSS so I can get intersection of lines along SVG circle.
Here is my JSfiddle code where I tried to add lines to SVG circle.
http://jsfiddle.net/sreeram62/8QRAJ/
<svg height="210" width="500">
<circle cx="50" cy="50" r="5" stroke="black" stroke-width="0" fill="#00FFFF" />
Sorry, your browser does not support inline SVG.
</svg>
circle:after {
content: '';
display: block;
height: 1px;
width: 300px;
position: absolute;
top: 50%;
left: -125px;
background-color: #f00;
}
circle:before {
content: '';
display: block;
height: 300px;
width: 1px;
position: absolute;
left: 50%;
top: -125px;
background-color: #f00;
}
I think it's impossible or too hard, but I made sample code for this.
I use inline svg at filter property of circle element.
When I tested, this code worked fine at firefox only, not at chrome.
(I don't know this sample is useful for using google maps.)
see http://jsfiddle.net/defghi1977/39gjd/
svg:
<svg width="200px" height="200px" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<circle cx="100" cy="100" r="10" fill="red"/>
</svg>
css:
circle{
filter: url("data:image/svg+xml;utf-8,<svg xmlns='http://www.w3.org/2000/svg'><defs><filter id='f' x='-3' y='-3' width='7' height='7' primitiveUnits='objectBoundingBox'><feFlood flood-color='black' x='-3' y='0.45' width='7' height='0.1' result='hb'/><feFlood flood-color='black' x='0.45' y='-3' width='0.1' height='7' result='vb'/><feMerge><feMergeNode in='SourceGraphic'/><feMergeNode in='hb'/><feMergeNode in='vb'/></feMerge></filter></defs></svg>#f");
}

Resources