Border-image gradient pattern in triangle shape - css

I want to create an odd shaped triangle with css. My first thought was to use transparent borders with transform: rotate and it worked (see left triangle). Now I want to use a gradient border image pattern as background for a same triangle but I can't make it work. I tried many things like changing border-width, using wrappers and overflow:hidden among others, nothing worked. Here I post one of my tries (see right shape) as you see the pattern takes all the space, not following the triangle shape. Any ideas?
#top-left {
position:absolute;
left:78px;
width: 0;
height: 0;
border-top: 100px solid transparent;
border-right: 80px solid black;
border-bottom: 50px solid transparent;
-webkit-transform: rotate(-20deg);
}
#top-right {
position:absolute;
left:300px;
width: 0;
height: 0;
border-image: repeating-linear-gradient( 0deg, pink, pink 1%, purple 1%, purple 8%) 10;
border-image-width: 100px 80px 50px 0px;
border-width: 100px 80px 50px 0px;
border-style: solid;
-webkit-transform: rotate(-20deg);
}
<div id="wrapper">
<div id="top-left"></div>
<div id="top-right"></div>
</div>
Edit: Andrey Fedorov's answer is good, but there is a problem when the background is not a solid color, like this for example:
body{
background-color: #6d695c;
background-image:
repeating-linear-gradient(120deg, rgba(255,255,255,.1), rgba(255,255,255,.1) 1px, transparent 1px, transparent 60px),
repeating-linear-gradient(60deg, rgba(255,255,255,.1), rgba(255,255,255,.1) 1px, transparent 1px, transparent 60px),
linear-gradient(60deg, rgba(0,0,0,.1) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.1) 75%, rgba(0,0,0,.1)),
linear-gradient(120deg, rgba(0,0,0,.1) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.1) 75%, rgba(0,0,0,.1));
background-size: 70px 120px;
}
#wrapper {
position: relative;
}
#top-left {
position:absolute;
left:0px;
width: 0;
height: 0;
border-top: 100px solid #fff;
border-right: 80px solid transparent;
border-bottom: 50px solid #fff;
-webkit-transform: rotate(-20deg);
}
#top-right {
position:absolute;
z-index: -10;
left:0;
width: 0;
height: 0;
border-image: repeating-linear-gradient( 0deg, pink, pink 1%, purple 1%, purple 8%) 10;
border-image-width: 100px 80px 50px 0px;
border-width: 100px 80px 50px 0px;
border-style: solid;
-webkit-transform: rotate(-20deg);
}
<div id="wrapper">
<div id="top-left"></div>
<div id="top-right"></div>
</div>

You still can use linear-gradient with no-repeat and background-size to draw each pieces :
examples by steps from a single tag :
/* testing gradients */
p , div#wrapper {
width:80px;
float:left;
margin:1em;
height:150px;
/* see me then remove this shadow */
box-shadow:0 0 0 2px;
}
p {
background:
linear-gradient(130deg, transparent 49.75%, pink 50.5%) 0 42px no-repeat ;
background-size:
100% 15px;
transform: rotate(-20deg);
}
p + p{
background:
linear-gradient(130deg, transparent 49.75%, pink 50.5%) 0 42px no-repeat ,
linear-gradient(130deg,transparent 62px, purple 63px) top no-repeat;
background-size:
100% 15px,
100% 65%;
}
p + p + p {
background:
linear-gradient(130deg, transparent 49.75%, pink 50.5%) 0 42px no-repeat ,
linear-gradient(130deg,transparent 62px, purple 63px) top no-repeat,
linear-gradient(33deg , transparent 42px, pink 43px) no-repeat bottom;
background-size:
100% 15px,
100% 65%,
100% 8px;
}
p+ p + p + p {
background:
linear-gradient(130deg, transparent 49.75%, pink 50.5%) 0 42px no-repeat ,
linear-gradient(130deg,transparent 62px, purple 63px) top no-repeat,
linear-gradient(33deg , transparent 42px, pink 43px) no-repeat bottom,
linear-gradient(33deg, transparent 42px, purple 43px) bottom no-repeat;
background-size:
100% 15px,
100% 65%,
100% 8px,
100% 35.5%;
}
p:last-of-type{
box-shadow:0 0
}
/* your original CSS/issue */
body{
background-color: #6d695c;
background-image:
repeating-linear-gradient(120deg, rgba(255,255,255,.1), rgba(255,255,255,.1) 1px, transparent 1px, transparent 60px),
repeating-linear-gradient(60deg, rgba(255,255,255,.1), rgba(255,255,255,.1) 1px, transparent 1px, transparent 60px),
linear-gradient(60deg, rgba(0,0,0,.1) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.1) 75%, rgba(0,0,0,.1)),
linear-gradient(120deg, rgba(0,0,0,.1) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.1) 75%, rgba(0,0,0,.1));
background-size: 70px 120px;
}
#wrapper {
position: relative;
}
#top-left {
position:absolute;
left:0px;
width: 0;
height: 0;
border-top: 100px solid #fff;
border-right: 80px solid transparent;
border-bottom: 50px solid #fff;
-webkit-transform: rotate(-20deg);
transform: rotate(-20deg);
}
#top-right {
position:absolute;
z-index: -10;
left:0;
width: 0;
height: 0;
border-image: repeating-linear-gradient( 0deg, pink, pink 1%, purple 1%, purple 8%) 10;
border-image-width: 100px 80px 50px 0px;
border-width: 100px 80px 50px 0px;
border-style: solid;
-webkit-transform: rotate(-20deg);
transform: rotate(-20deg);
}
<!-- your issue -->
<div id="wrapper">
<div id="top-left"></div>
<div id="top-right"></div>
</div>
<!-- p for testing purpose -->
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
inbricated element + gradient & transform could do too:
body{
background-color: #6d695c;
background-image:
repeating-linear-gradient(120deg, rgba(255,255,255,.1), rgba(255,255,255,.1) 1px, transparent 1px, transparent 60px),
repeating-linear-gradient(60deg, rgba(255,255,255,.1), rgba(255,255,255,.1) 1px, transparent 1px, transparent 60px),
linear-gradient(60deg, rgba(0,0,0,.1) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.1) 75%, rgba(0,0,0,.1)),
linear-gradient(120deg, rgba(0,0,0,.1) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.1) 75%, rgba(0,0,0,.1));
background-size: 70px 120px;
}
div.inbricate {
margin:1em;
height:150px;
width:80px;
position:relative;
overflow:hidden;
transform:rotate(-20deg);
box-shadow: 0 0 ;
}
.inbricate div {
transform:rotate(31deg) scale(1.2, 0.9) skew(-5deg);
transform-origin: 100% 102%;
height:100%;
background:linear-gradient(-40deg, pink 8%, purple 8%, purple 65%, pink 65%, pink 75%, purple 75% )
}
<div class=inbricate>
<div>
</div>
</div>

One possible solution is this:
Put both shapes in the same place.
Using z-index make the one with the pattern go behind the other
Use white (or whatever color is the shape background) to paint the border area outside the triangle.
Make transparent the border that had the triangle color
#wrapper {
position: relative;
}
#top-left {
position:absolute;
left:0px;
width: 0;
height: 0;
border-top: 100px solid #fff;
border-right: 80px solid transparent;
border-bottom: 50px solid #fff;
-webkit-transform: rotate(-20deg);
}
#top-right {
position:absolute;
z-index: -10;
left:0;
width: 0;
height: 0;
border-image: repeating-linear-gradient( 0deg, pink, pink 1%, purple 1%, purple 8%) 10;
border-image-width: 100px 80px 50px 0px;
border-width: 100px 80px 50px 0px;
border-style: solid;
-webkit-transform: rotate(-20deg);
}
<div id="wrapper">
<div id="top-left"></div>
<div id="top-right"></div>
</div>

Related

How to make it rain everywhere?

I would like to create a raining-effect for my weather app with CSS-only. However, even though I achieved satisfying results with the look, I can't seem to make them cover the entire screen continuously and not just random chunks of it - how would I go about this?
body {
overflow: hidden;
}
#background {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
#background.night {
background: linear-gradient(#0F2129, #47334A);
}
#background>.cloud {
width: 900px;
height: 900px;
position: absolute;
background-color: #fff;
border-radius: 50%;
animation: cloud 10s infinite alternate;
}
#background.rain>.cloud {
opacity: .5;
}
#background>.cloud:nth-child(even) {
animation-delay: 3s;
}
#background.night>.cloud {
background-color: grey;
}
#background.rain>.cloud:before,
#background.rain>.cloud:after {
animation: rain 1s infinite linear;
content: '';
border-radius: 50%;
display: block;
height: 6px;
width: 3px;
opacity: 1;
margin-top: 700px;
}
#background.rain>.cloud:after {
transform: translate(50px);
}
#background.rain>.cloud:nth-child(even):before,
#background.rain>.cloud:nth-child(even):after {
animation-delay: .3s;
}
#keyframes rain {
0% {
box-shadow: #cccccc 30px 30px, #cccccc 40px 40px, #cccccc 50px 75px, #cccccc 55px 50px, #cccccc 70px 100px, #cccccc 80px 95px, #cccccc 110px 45px, #cccccc 75px 50px, #cccccc 80px 20px, #cccccc 65px 40px, #cccccc 100px 80px, #cccccc 45px 85px, #cccccc 95px 50px, #cccccc 90px 35px;
}
100% {
box-shadow: #cccccc 30px 970px, #cccccc 40px 980px, #cccccc 50px 945px, #cccccc 55px 980px, #cccccc 70px 960px, #cccccc 80px 945px, #cccccc 110px 995px, #cccccc 75px 950px, #cccccc 80px 920px, #cccccc 65px 940px, #cccccc 100px 980px, #cccccc 45px 985px, #cccccc 95px 950px, #cccccc 90px 985px;
}
}
#keyframes cloud {
100% {
transform: translate(-50px) scale(1.05);
}
}
<div id="background" class="rain night">
<div class="cloud" style="top: -797.689px; left: -315px;"></div>
<div class="cloud" style="top: -865.689px; left: -225px;"></div>
<div class="cloud" style="top: -814.689px; left: -65px;"></div>
<div class="cloud" style="top: -853.689px; left: 253px;"></div>
<div class="cloud" style="top: -823.689px; left: 23px;"></div>
<div class="cloud" style="top: -843.689px; left: 109px;"></div>
</div>
This is a good job for some random radial-gradient that you repeat. Not linear-gradient because you will have a hard time creating spaces between repetition (maybe impossible).
Here is a basic example. We use the same gradient at different random position and all will repeat:
html {
height:100%;
background: linear-gradient(#0F2129, #47334A);
overflow:hidden;
}
html:before {
content:"";
position:absolute;
bottom:0;
right:0;
left:0;
height:calc(100% + 100px); /* should be bigger than (100% + 55px)*/
background:
radial-gradient(2px 8px,#cccccc 100%,transparent 100%) -12px 3px,
radial-gradient(2px 8px,#cccccc 100%,transparent 100%) 17px 0,
radial-gradient(2px 8px,#cccccc 100%,transparent 100%) 6px 12px,
radial-gradient(2px 8px,#cccccc 100%,transparent 100%) 24px 23px,
radial-gradient(2px 8px,#cccccc 100%,transparent 100%) 39px 30px,
radial-gradient(2px 8px,#cccccc 100%,transparent 100%) 5px 43px;
background-size:50px 55px;
animation:rain 0.2s linear infinite;
}
#keyframes rain{
to {
transform:translateY(55px); /* Same as the height of the background-size */
}
}
And if you want a litte skewing:
html {
height:100%;
background: linear-gradient(#0F2129, #47334A);
overflow:hidden;
}
html:before {
content:"";
position:absolute;
bottom:0;
right:-20%;
left:-20%;
height:calc(100% + 100px); /* should be bigger than (100% + 55px)*/
background:
radial-gradient(2px 8px,#cccccc 100%,transparent 100%) -12px 3px,
radial-gradient(2px 8px,#cccccc 100%,transparent 100%) 17px 0,
radial-gradient(2px 8px,#cccccc 100%,transparent 100%) 6px 12px,
radial-gradient(2px 8px,#cccccc 100%,transparent 100%) 24px 23px,
radial-gradient(2px 8px,#cccccc 100%,transparent 100%) 39px 30px,
radial-gradient(2px 8px,#cccccc 100%,transparent 100%) 5px 43px;
background-size:50px 55px;
animation:rain 0.2s linear infinite;
transform:skew(-8deg);
}
#keyframes rain{
to {
transform:skew(-8deg) translateY(55px); /* Same as the height of the background-size */
}
}
And with CSS variables to easily control:
html {
height:100%;
background: linear-gradient(#0F2129, #47334A);
overflow:hidden;
--s:2px 8px; /* size of drop of water*/
--c:#ccc; /* color of the water*/
--a:-7deg; /* control the skewing*/
--w:50px; /* width of the pattern*/
--h:55px; /* height of the pattern*/
--rad:radial-gradient(var(--s),var(--c) 100%,transparent 100%)
}
html:before {
content:"";
position:absolute;
bottom:0;
right:-20%;
left:-20%;
height:calc(100% + var(--h) + 10px); /* should be bigger than (100% + var(--h))*/
background:
var(--rad) -12px 3px,
var(--rad) 17px 0,
var(--rad) 6px 12px,
var(--rad) 24px 23px,
var(--rad) 39px 30px,
var(--rad) 5px 43px;
background-size:var(--w) var(--h);
animation:rain 0.2s linear infinite;
transform:skew(var(--a));
}
#keyframes rain{
to {
transform:skew(var(--a)) translateY(var(--h)); /* Same as the height of the background-size */
}
}
You can consider two layers with a different pattern for another kind of animation (more random)
html {
height:100%;
background: linear-gradient(#0F2129, #47334A);
overflow:hidden;
--s:2px 8px; /* size of drop of water*/
--c:#ccc; /* color of the water*/
--a:-7deg; /* control the skewing*/
--w:53px; /* width of the pattern*/
--h:55px; /* height of the pattern*/
--rad:radial-gradient(var(--s),var(--c) 100%,transparent 100%)
}
html:before,
html:after{
content:"";
position:absolute;
bottom:0;
right:-20%;
left:-20%;
height:calc(100% + var(--h) + 10px); /* should be bigger than (100% + var(--h))*/
background:
var(--rad) -12px 3px,
var(--rad) 17px 0,
var(--rad) 6px 12px,
var(--rad) 24px 23px,
var(--rad) 39px 30px,
var(--rad) 5px 43px;
background-size:var(--w) var(--h);
animation:rain 0.2s linear infinite;
transform:skew(var(--a));
}
html:after {
--h:70px;
--w:61px;
}
#keyframes rain{
to {
transform:skew(var(--a)) translateY(var(--h)); /* Same as the height of the background-size */
}
}
I think you were missing some margin-left
body {
overflow: hidden;
}
#background {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
#background.night {
background: linear-gradient(#0F2129, #47334A);
}
#background>.cloud {
width: 900px;
height: 900px;
position: absolute;
background-color: #fff;
border-radius: 50%;
animation: cloud 10s infinite alternate;
}
#background.rain>.cloud {
opacity: .5;
}
#background>.cloud:nth-child(even) {
animation-delay: 3s;
}
#background.night>.cloud {
background-color: grey;
}
#background.rain>.cloud:before,
#background.rain>.cloud:after {
animation: rain 1s infinite linear;
content: '';
border-radius: 50%;
display: block;
height: 6px;
width: 3px;
opacity: 1;
margin-top: 700px;
margin-left:400px;
}
#background.rain>.cloud:after {
transform: translate(50px);
}
#background.rain>.cloud:nth-child(even):before,
#background.rain>.cloud:nth-child(even):after {
animation-delay: .3s;
}
#keyframes rain {
0% {
box-shadow: #cccccc 30px 30px, #cccccc 40px 40px, #cccccc 50px 75px, #cccccc 55px 50px, #cccccc 70px 100px, #cccccc 80px 95px, #cccccc 110px 45px, #cccccc 75px 50px, #cccccc 80px 20px, #cccccc 65px 40px, #cccccc 100px 80px, #cccccc 45px 85px, #cccccc 95px 50px, #cccccc 90px 35px;
}
100% {
box-shadow: #cccccc 30px 970px, #cccccc 40px 980px, #cccccc 50px 945px, #cccccc 55px 980px, #cccccc 70px 960px, #cccccc 80px 945px, #cccccc 110px 995px, #cccccc 75px 950px, #cccccc 80px 920px, #cccccc 65px 940px, #cccccc 100px 980px, #cccccc 45px 985px, #cccccc 95px 950px, #cccccc 90px 985px;
}
}
#keyframes cloud {
100% {
transform: translate(-50px) scale(1.05);
}
}
<div id="background" class="rain night">
<div class="cloud" style="top: -797.689px; left: -315px;"></div>
<div class="cloud" style="top: -865.689px; left: -225px;"></div>
<div class="cloud" style="top: -814.689px; left: -65px;"></div>
<div class="cloud" style="top: -853.689px; left: 253px;"></div>
<div class="cloud" style="top: -823.689px; left: 23px;"></div>
<div class="cloud" style="top: -843.689px; left: 109px;"></div>
</div>

Get dash-dot and dash-dot-dot border using CS [duplicate]

How to created dash dot and dash dot dot lines and rectangles like
in CSS without using external links to images or other (inline data urls can used if there is no better way).
https://codepen.io/ibrahimjabbari/pen/ozinB
contains some samples like
hr.style17:after {
content: 'ยง';
display: inline-block;
position: relative;
top: -14px;
padding: 0 10px;
background: #f0f0f0;
color: #8c8b8b;
font-size: 18px;
-webkit-transform: rotate(60deg);
-moz-transform: rotate(60deg);
transform: rotate(60deg);
}
. It uses content and rotate CSS properties, maybe those can used.
You can try a combination of repeating-linear-gradient and radial-gradient
.dash-dot {
height:50px;
background:
radial-gradient(circle at center,#000 2px,transparent 3px) 5px 50%/20px 5px repeat-x,
repeating-linear-gradient(to right,#000,#000 10px,transparent 10px,transparent 20px) center/100% 3px no-repeat
}
.dash-dot-dot {
height:50px;
background:
radial-gradient(circle at center,#000 2px,transparent 3px) 0px 50%/30px 5px repeat-x,
radial-gradient(circle at center,#000 2px,transparent 3px) 10px 50%/30px 5px repeat-x,
repeating-linear-gradient(to right,#000,#000 10px,transparent 10px,transparent 30px) center/100% 3px no-repeat;
}
<div class="dash-dot"></div>
<div class="dash-dot-dot"></div>
To have a rectangle you need to repeat the same on each side:
.dash-dot {
height:210px;
background:
/*right*/
repeating-linear-gradient(to bottom,#000,#000 10px,transparent 10px,transparent 20px) calc(100% - 1px) 0/3px 100% no-repeat,
radial-gradient(circle at center,#000 2px,transparent 3px) 100% 5px/5px 20px repeat-y,
/*left*/
repeating-linear-gradient(to bottom,#000,#000 10px,transparent 10px,transparent 20px) 1px 0/3px 100% no-repeat,
radial-gradient(circle at center,#000 2px,transparent 3px) 0 5px/5px 20px repeat-y,
/*top*/
repeating-linear-gradient(to right,#000,#000 10px,transparent 10px,transparent 20px) 0 1px/100% 3px no-repeat,
radial-gradient(circle at center,#000 2px,transparent 3px) 5px 0/20px 5px repeat-x,
/*bottom*/
repeating-linear-gradient(to right,#000,#000 10px,transparent 10px,transparent 20px) 0 calc(100% - 1px)/100% 3px no-repeat,
radial-gradient(circle at center,#000 2px,transparent 3px) 5px 100%/20px 5px repeat-x;
}
<div class="dash-dot"></div>

CSS Stripes, repeating-linear-gradient bug

I have a striped divider in CSS, with repeating linear gradient, but it is doing some strange thing, here is an image :
As you can see, the thickness of some of the stripes are not the same, I would like to have the striped divider like this, but all with the same "font-weight", I tried to fix the code adding or reducing pixels, but not working
Here is the code :
.striped_divider {
height: 20px;
background: -webkit-repeating-linear-gradient(135deg, transparent 2px, transparent 7px,#cccccc 8px,#cccccc 8px);
background: -o-repeating-linear-gradient(135deg, transparent 2px, transparent 7px,#cccccc 8px,#cccccc 8px);
background: repeating-linear-gradient(-45deg, transparent 2px, transparent 7px,#cccccc 8px,#cccccc 8px);
}
<div class="striped_divider"></div>
You can do nothing, this is how gradient are rendred when we deal with small close values (especially in Google Chrome, in Fiferfox it should be better).
Increase the values and you will see that the effect will slowly disappear:
.striped_divider0 {
height: 20px;
margin:5px;
background: repeating-linear-gradient(-45deg, transparent 2px, transparent 7px, #cccccc 8px, #cccccc 8px);
}
.striped_divider {
height: 20px;
margin:5px;
background: repeating-linear-gradient(-45deg, transparent 2px, transparent 7px, #cccccc 7px, #cccccc 8px);
}
.striped_divider1 {
height: 20px;
margin:5px;
background: repeating-linear-gradient(-45deg, transparent 2px, transparent 7px, #cccccc 7px, #cccccc 10px);
}
.striped_divider2 {
height: 20px;
margin:5px;
background: repeating-linear-gradient(-45deg, transparent 2px, transparent 7px, #cccccc 7px, #cccccc 15px);
}
<div class="striped_divider0"></div>
<div class="striped_divider"></div>
<div class="striped_divider1"></div>
<div class="striped_divider2"></div>
You can try skew transformation, it should give better result:
.striped_divider {
height: 20px;
margin: 5px;
background: repeating-linear-gradient(to right, transparent 2px, transparent 9px, #cccccc 10px, #cccccc 10px);
transform: skew(-45deg);
}
.striped_divider1 {
height: 20px;
margin: 5px;
background: repeating-linear-gradient(-45deg, transparent 2px, transparent 7px, #cccccc 8px, #cccccc 8px);
}
<div class="striped_divider"></div>
<div class="striped_divider1"></div>
As you can see in the example below (I've added a css zoom) the lines are indeed the same width. As #Roy already said, it's just an optical illusion.
Edit: I noticed I didn't provide you with a possible solution. As already noted by #Roy, a possible solution would be to repeat an image. The image doesn't have to be particularly high quality, so I don't think it will influence your performance.
.striped_divider {
height: 20px;
background: -webkit-repeating-linear-gradient(135deg, transparent 2px, transparent 7px,#cccccc 8px,#cccccc 8px);
background: -o-repeating-linear-gradient(135deg, transparent 2px, transparent 7px,#cccccc 8px,#cccccc 8px);
background: repeating-linear-gradient(-45deg, transparent 2px, transparent 7px,#cccccc 8px,#cccccc 8px);
transform: scale(2.5);
}
<div class="striped_divider"></div>
It indeed seems like a rendering issue, at least in Chrome.
To get around this, you can use linear-gradient & background-size instead:
.striped_divider {
height: 20px;
background-image: linear-gradient(-45deg,
#cccccc 6.25%,
#ffffff 6.25%,
#ffffff 50%,
#cccccc 50%,
#cccccc 56.25%,
#ffffff 56.25%,
#ffffff 100%
);
background-size: 8px 8px;
}
<div class="striped_divider"></div>
I made this using https://stripesgenerator.com

Infinite chevron line

I don't how it can't be named in english - I neither don't know in french to be honest - but I need to design an infinite line composed by normal and invert chevron. It's seems to be called a chevron line.
Here's an example of what I want and I only need one line :
Here what I've done so far with before and after pseudo elements. Maybe there's another way that i can't think of. Right now i didn't achieve to display it as chevron, i don't understand how repeating linear gradient works for the position.
.chevron-line {
position: relative;
height: 15px;
background: white;
}
.chevron-line::before,
.chevron-line::after {
content: '';
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.chevron-line::before {
background: repeating-linear-gradient(135deg,
#000, #000 5px /* black stripe */,
transparent 0, transparent 20px /* blue stripe */
);
}
.chevron-line::after {
background: repeating-linear-gradient(-135deg,
transparent 0px, transparent 10px /* blue stripe */,
#000, #000 15px /* black stripe */,
transparent 0px, transparent 20px /* blue stripe */
);
}
<div class="chevron-line"></div>
you can do this with css gradient
div.box {
height: 500px;
background:
linear-gradient(135deg, #ffffff 25%, transparent 25%) -50px 0,
linear-gradient(225deg, #ffffff 25%, transparent 25%) -50px 0,
linear-gradient(315deg, #ffffff 25%, transparent 25%),
linear-gradient(45deg, #ffffff 25%, transparent 25%);
background-size: 100px 100px;
background-color: #000000;
}
<div class="box">
</div>
make it thin like this
div.box {
height: 500px;
background:
linear-gradient(135deg, #ffffff 35%, transparent 35%) -50px 0,
linear-gradient(225deg, #ffffff 35%, transparent 35%) -50px 0,
linear-gradient(315deg, #ffffff 35%, transparent 35%),
linear-gradient(45deg, #ffffff 35%, transparent 35%);
background-size: 100px 100px;
background-color: #000000;
}
<div class="box"></div>

How to make a responsive circle with transparent horizontal lines inside it in CSS?

I do not know if this is even possible with only css. I want to make a circle with transparent horizontal lines and you can change size and position of each of these lines. Something like this png picture:
I did this so far, but it is not responsive it has not transparent lines inside, but you can move all lines freely.
.enjoy-css {
box-sizing: content-box;
width: 300px;
height: 300px;
position: absolute;
border: none;
border-radius: 150px;
background: linear-gradient(white, white), linear-gradient(white, white), linear-gradient(white, white), linear-gradient(white, white), linear-gradient(white, white)black;
background-repeat: no-repeat;
background-position: 90% 90%, 55% 75%, 90% 10%, 95% 30%, 90%;
background-origin: padding-box;
background-size: 124px 20px, 153px 20px, 124px 20px, 153px 20px, 80px 20px;
}
<div class="enjoy-css">
<span></span>
</div>
You can use svg to create the responsive shapes like below.
For this first you have to create the svg of your shape inside svg <symbol> tag so that you can use this later.
Then create a div having class enjoy-css and then use the previously created svg using <use>. Don't forget to give width="100%" to the <svg> for responsive purpose
svg.defs-only {
display: block;
position: absolute;
height: 0;
width: 0;
margin: 0;
padding: 0;
border: none;
overflow: hidden;
}
body {
background: gold;
}
.enjoy-css {
max-width: 400px;
}
<svg class="defs-only" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="400px" height="400px">
<symbol id="potofgold" >
<path fill-rule="evenodd" fill="rgb(0, 0, 0)"
d="M387.395,270.000 L154.000,270.000 L154.000,298.000 L374.370,298.000 C368.372,308.648 361.409,318.675 353.632,328.000 L103.000,328.000 L103.000,356.000 L325.121,356.000 C290.863,383.519 247.363,400.000 200.000,400.000 C89.543,400.000 0.000,310.457 0.000,200.000 C0.000,177.987 3.567,156.809 10.136,137.000 L263.000,137.000 L263.000,109.000 L21.855,109.000 C28.645,95.734 36.895,83.344 46.356,72.000 L238.000,72.000 L238.000,44.000 L74.879,44.000 C109.140,16.485 152.638,0.000 200.000,0.000 C310.457,0.000 400.000,89.543 400.000,200.000 C400.000,224.628 395.538,248.212 387.395,270.000 ZM326.000,187.000 L63.000,187.000 L63.000,215.000 L326.000,215.000 L326.000,187.000 Z"/>
</symbol>
</svg>
<div class="enjoy-css"><svg viewBox="0 0 400 400" width="100%"><use xlink:href="#potofgold"/></svg></div>
This is it:
body {
background: #aaa;
background: url(http://www.lorempixel.com/600/600/abstract); /* background to show transparency */
}
.circle {
max-width: 20em; /* Set the max diameter */
margin: 0 auto;
}
.circle span {
position: relative;
display: block;
padding-bottom: 100%;
}
.circle span::after {
content: "";
display: block;
position: absolute;
width: 100%;
top: 0;
bottom: 0;
border-radius: 50%;
background-image: linear-gradient(
black 10%,
transparent 10%,
transparent 18%,
black 18%,
black 28%,
transparent 28%,
transparent 36%,
black 36%,
black 45%,
transparent 45%,
transparent 55%,
black 55%,
black 64%,
transparent 64%,
transparent 72%,
black 72%,
black 82%,
transparent 82%,
transparent 90%,
black 90%
),
linear-gradient(to right, transparent 60%, black 60%),
linear-gradient(to right, transparent 70%, black 70%),
linear-gradient(
to right,
black 15%,
transparent 15%,
transparent 85%,
black 85%
),
linear-gradient(to left, transparent 60%, black 60%),
linear-gradient(to left, transparent 70%, black 70%);
background-size: 100%, 100% 20%, 100% 40%, 100% 20%, 100% 20%, 100% 20%;
background-position: top, top, top, 40%, 0 70%, 0 90%;
background-repeat: no-repeat;
}
<!DOCTYPE html>
<html>
<body>
<div class="circle">
<span></span>
</div>
</body>
</html>

Resources