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

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>

Related

Hot to make gradient half red / half blue?

Currently the whole thing is red.
How would I make this gradient, half the left side red, half blue?
That is all I am trying to do in the code.
div {
width: 640px;
height: 340px;
background:
linear-gradient(45deg,
transparent,
transparent 7px,
red 7px,
red 7.5px,
transparent 7.5px,
transparent 10px),
linear-gradient(-45deg,
transparent,
transparent 7px,
red 7px,
red 7.5px,
transparent 7.5px,
transparent 10px);
background-size: 10px 10px;
}
<div></div>
Use your gradient configuration inside mask then consider a regular background for your separation. I optimized you gradient configuration a little as well:
div {
width: 640px;
height: 340px;
background: linear-gradient(90deg, red 50%,blue 0);
-webkit-mask:
linear-gradient( 45deg, #0000 7px, #000 0 7.5px, #0000 0 10px),
linear-gradient(-45deg, #0000 7px, #000 0 7.5px, #0000 0 10px);
-webkit-mask-size: 10px 10px;
}
<div></div>
You could use repeating-linear-gradient, background-size, background-position , background-repeat and background-position all together. So you can lay on different areas differents sized gradients
Possible example:
div {
border:solid;
width: 640px;
aspect-ratio:3/1.5;
background:
repeating-linear-gradient( 45deg,transparent 0 7px,red 7px 8px,transparent 8px 10px) 0 0 / 50% 100% no-repeat,
repeating-linear-gradient(135deg,transparent 0 7px,red 7px 8px,transparent 8px 10px) 0 0 / 50% 100% no-repeat,
repeating-linear-gradient(225deg,transparent 0 7px,blue 7px 8px,transparent 8px 10px) 100% 0 / 50% 100% no-repeat,
repeating-linear-gradient(135deg,transparent 0 7px,blue 7px 8px,transparent 8px 10px) 100% 0px / 50% 100% no-repeat
ivory /* bgcolor */
}
<div></div>
On top of half of the block we place the layer in a pseudo-element with a css filter on the background. Filter properties are different. In our case, we apply a filter that rotates the hue palette backdrop-filter: hue-rotate(240deg) so that the red becomes blue. 240deg means rotate 240 degrees clockwise.
div {
width: 640px;
height: 340px;
background: linear-gradient(45deg, transparent, transparent 7px, red 7px, red 7.5px, transparent 7.5px, transparent 10px), linear-gradient(-45deg, transparent, transparent 7px, red 7px, red 7.5px, transparent 7.5px, transparent 10px);
background-size: 10px 10px;
position: relative;
}
div::after {
position: absolute;
left: 50%;
top: 0;
display: block;
width: 50%;
height: 100%;
content: '';
backdrop-filter: hue-rotate(240deg);
}
<div></div>

CSS: animated offset image border

so, i'm trying to achieve this kind of animated border with css
sample of the border
the sample animated css is:
#keyframes bg {
0% {
background-size: 0 3px,
3px 0,
0 3px,
3px 0;
}
25% {
background-size: 100% 3px,
3px 0,
0 3px,
3px 0;
}
50% {
background-size: 100% 3px,
3px 100%,
0 3px,
3px 0;
}
75% {
background-size: 100% 3px,
3px 100%,
100% 3px,
3px 0;
}
100% {
background-size: 100% 3px,
3px 100%,
100% 3px,
3px 100%;
}
}
div {
width: 25%;
margin: 2rem auto;
padding: 2em;
background-repeat: no-repeat;
background-image: linear-gradient(to right, #f5ca00 100%, #f5ca00 100%),
linear-gradient(to bottom, #f5ca00 100%, #f5ca00 100%),
linear-gradient(to right, #f5ca00 100%, #f5ca00 100%),
linear-gradient(to bottom, #f5ca00 100%, #f5ca00 100%);
background-size: 100% 3px,
3px 100%,
100% 3px,
3px 100%;
background-position: 0 0,
100% 0,
100% 100%,
0 100%;
animation: bg 1.25s cubic-bezier(0.19, 1, 0.22, 1) 1;
animation-play-state: paused;
}
div:hover {
animation-play-state: running;
}
<div>
<img src="https://moro.fund/wp-content/uploads/2020/08/scale-photo.png" alt="">
</div>
i just want the last animated line to be half and inside the image just like the sample at the start :)
please note that is gonna be used inside wordpress.
any kind of help or guidance is appreciated.
Try to add to div styles with :after pseudo class and animate it on hover or on initail animations.
#keyframes bg {
0% {
background-size: 0 3px,
3px 0,
0 3px,
3px 0;
}
25% {
background-size: 100% 3px,
3px 0,
0 3px,
3px 0;
}
50% {
background-size: 100% 3px,
3px 100%,
0 3px,
3px 0;
}
75% {
background-size: 100% 3px,
3px 100%,
100% 3px,
3px 0;
}
100% {
background-size: 100% 3px,
3px 100%,
100% 3px,
3px 100%;
}
}
div {
width: 25%;
margin: 2rem auto;
padding: 2em;
background-repeat: no-repeat;
background-image: linear-gradient(to right, #f5ca00 100%, #f5ca00 100%),
linear-gradient(to bottom, #f5ca00 100%, #f5ca00 100%),
linear-gradient(to right, #f5ca00 100%, #f5ca00 100%),
linear-gradient(to bottom, #f5ca00 100%, #f5ca00 100%);
background-size: 100% 3px,
3px 100%,
100% 3px,
3px 100%;
background-position: 0 0,
100% 0,
100% 100%,
0 100%;
animation: bg 1.25s cubic-bezier(0.19, 1, 0.22, 1) 1;
animation-play-state: paused;
position: relative;
}
div:hover {
animation-play-state: running;
}
div:after{
content: '';
width: 2px;
height: 0;
background: #f5ca00;
position: absolute;
right: 0;
top: 0;
transition: height .3s ease;
}
div:hover:after {
height: 100px;
}
<div>
<img src="https://moro.fund/wp-content/uploads/2020/08/scale-photo.png" alt="">
</div>

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>

How can I code this menu icon with only CSS and one element?

I have tried so far.
body {
margin:0;
padding:20px;
background-color: #000;
}
.mobil-menu__icon {
height: 50px;
width: 50px;
background:
linear-gradient(to bottom, #fff 0%, #fff 20%, transparent 20%, transparent 100%),
linear-gradient(to bottom, transparent 0%, transparent 40%, #fff 40%, #fff 60%, transparent 60%, transparent 100%),
linear-gradient(to bottom, transparent 0%, transparent 80%, #fff 80%, #fff 100%);
}
<div class="mobil-menu__icon"></div>
Use only solid color in gradient and rely on background-size:
.mobil-menu__icon {
height: 50px;
width: 50px;
background:
/* position / width height */
linear-gradient(#fff,#fff) top left / 100% 20%,
linear-gradient(#fff,#fff) center left / 80% 20%,
linear-gradient(#fff,#fff) bottom left / 60% 20%,
red;
border:10px solid red;
background-repeat:no-repeat; /* Never forget this! */
}
<div class="mobil-menu__icon"></div>
With hover animation:
.mobil-menu__icon {
height: 50px;
width: 50px;
background:
linear-gradient(#fff,#fff) top left,
linear-gradient(#fff,#fff) center left,
linear-gradient(#fff,#fff) bottom left,
red;
background-size:
100% 20%,
80% 20%,
60% 20%;
border:10px solid red;
background-repeat:no-repeat;
transition:0.3s all;
}
.mobil-menu__icon:hover {
background-size:100% 20%;
}
<div class="mobil-menu__icon"></div>
And if you want with transparency:
.mobil-menu__icon {
height: 50px;
width: 50px;
background:
linear-gradient(red,red) 0 calc(1*100%/4) / 100% 20%,
linear-gradient(red,red) 0 calc(3*100%/4) / 100% 20%,
linear-gradient(red,red) 100% calc(2*100%/4) / 20% 20%,
linear-gradient(red,red) 100% calc(4*100%/4) / 40% 20%;
border:10px solid red;
background-repeat:no-repeat;
}
body {
background:repeating-linear-gradient(to right,white 0 5px,grey 10px);
}
<div class="mobil-menu__icon"></div>
You were also almost good with your code but you were missing the size and the repeat:
body {
margin: 0;
padding: 20px;
background-color: #000;
}
.mobil-menu__icon {
height: 50px;
width: 50px;
background:
linear-gradient(to bottom, #fff 0%, #fff 20%, transparent 20%, transparent 100%),
linear-gradient(to bottom, transparent 0%, transparent 40%, #fff 40%, #fff 60%, transparent 60%, transparent 100%),
linear-gradient(to bottom, transparent 0%, transparent 80%, #fff 80%, #fff 100%);
background-size:100% 100%,80% 100%, 60% 100%;
background-repeat:no-repeat;
}
<div class="mobil-menu__icon"></div>
Related question to get more details about the different values:
Using percentage values with background-position on a linear gradient

Border-image gradient pattern in triangle shape

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>

Resources