Any ideas how to implement a custom border in css using gradient to look exactly like the following image
Css gradient Implement 2 color dashed border
178 views Asked by mozenge At
3
There are 3 answers
0
On
Gradients combined with mask can do it:
.box {
width: 300px;
height: 200px;
position: relative;
}
.box:before {
content:"";
position: absolute;
inset:0;
padding: 4px; /* the border thickness */
background:
repeating-conic-gradient(pink 0 25%,blue 0 50%) /* update the colors here */
0 0/30px 20px round; /* update the size here (30px = width, 20px = height) */
-webkit-mask:
linear-gradient(#000 0 0) content-box,
linear-gradient(#000 0 0);
-webkit-mask-composite: xor;
mask-composite: exclude;
}
<div class="box"></div>
0
On
Can you place a div within a div such as this: https://jsfiddle.net/sdfpe5w9/
<div class="outer">
<div class="inner"></div>
</div>
body {
background: #999;
}
.outer {
background: white;
border: 2px dashed #000;
display: inline-block;
}
.inner {
width: 200px;
height: 100px;
background: #999;
}

Add a dashed border on a solid border.