You can make a typical CSS border
dashed or dotted. For example:
.box {
border: 1px dashed black;
border: 3px dotted red;
}
You don’t have all that much control over how big or long the dashes or gaps are. And you certainly can’t give the dashes slants, fading, or animation! You can do those things with some trickery though.
Amit Sheen build this really neat Dashed Border Generator:
The trick is using four multiple backgrounds. The background
property takes comma-separated values, so by setting four backgrounds (one along the top, right, bottom, and left) and sizing them to look like a border, it unlocks all this control.
So like:
.box {
background-image: repeating-linear-gradient(0deg, #333333, #333333 10px, transparent 10px, transparent 20px, #333333 20px), repeating-linear-gradient(90deg, #333333, #333333 10px, transparent 10px, transparent 20px, #333333 20px), repeating-linear-gradient(180deg, #333333, #333333 10px, transparent 10px, transparent 20px, #333333 20px), repeating-linear-gradient(270deg, #333333, #333333 10px, transparent 10px, transparent 20px, #333333 20px);
background-size: 3px 100%, 100% 3px, 3px 100% , 100% 3px;
background-position: 0 0, 0 0, 100% 0, 0 100%;
background-repeat: no-repeat;
}
I like gumdrops.
Or you may use svg: https://codepen.io/kartofelek007/pen/MWyYZwL
Why not use border-image?
Seems a little overkill for the same effect.
There’s also
border-image
, which creates borders from a sprite-like image:https://developer.mozilla.org/en-US/docs/Web/CSS/border-image
It could reproduce some, though not all, of these background-image borders.
I have implemented this css border with background image into items on table module with move attribute. So when you enter into mysite just moveoner into blog item to see animated css border
I tried this out but I was unable to make the round the border corners. Do you have any tips on how to get the corners to curve.
Try adding something like
border-radius: 16px;
to.box
.