How do I add a red border outside this 8 point star? Or is there a simple svg solution anyone knows of?
HTML
<div id="star8"></div>
CSS
#star8 {
border: 3px solid red;
background: blue; width: 80px;
height: 80px;
position: relative;
-webkit-transform: rotate(20deg);
-moz-transform: rotate(20deg);
-ms-transform: rotate(20deg);
-o-transform: rotate(20eg);
}
#star8:before {
content: "";
position: absolute;
top: 0;
left: 0;
height: 80px;
width: 80px;
background: blue;
-webkit-transform: rotate(135deg);
-moz-transform: rotate(135deg);
-ms-transform: rotate(135deg);
-o-transform: rotate(135deg);
}
Just overlay another rect over it in :after, covering up the red border. http://codepen.io/anon/pen/qbrQZa
You should also make
#star8:before
only 77x77 in size to make it fit.SVG solution
This can be created with a single svg path. Adding outline can be done with adding a stroke property to the path
you may use mix-blend-mode and eventually the other pseudo : DEMO
without
mix-blend-mode
butz-index
and:after
linear-gradient
) to hide the border parts unwanted and add some text inside : http://codepen.io/gc-nomade/pen/KWNmqwThe reason the div looks the way it does currently is that you don't actually have an 8 pointed star, you have 2 squares superimposed on one another.
The first step is to add the outline to the :before pseudo class. The second is to add an :after pseudo class with no outline, rotated to the same position as the original div, to cover the outline drawn by :before overlapping the original div.
Demo: https://jsfiddle.net/hj1eh6md/
and CSS: