CSS border effect, css border
Previous
This article introduces the CSS border effect in detail.
Translucent border
border:10px solid hsla(0, 0%, 100%,.5); background-clip:padding-box;
Sewing Effect
outline: 1px white dashed; outline-offset:-10px; border-radius:4%; background:#795548;
Border rounded corner
The idea is as follows: Set the rounded corner for the element, and set the outline for the outer layer. Fill the gap between the rounded corner and the right corner with a shadow. The shadow size is half of the radius of the rounded corner.
border-radius:10px; background: tan; outline:10px solid #655; box-shadow:0 0 0 5px #655;
Envelope border
There are two ways to implement the envelope border:
1. Use background gradient
padding:1em; border: 1em solid transparent; background: linear-gradient(white,white) padding-box,repeating-linear-gradient(-45deg, red 0, red 12.5%, transparent 0, transparent 25%, #58a 0, #58a 37.5%, transparent 0, transparent 50%) 0/5em 5em;
2. Use a border image
padding:1em; border: 1em solid transparent; border-image:repeating-linear-gradient(-45deg, red 0, red 1em, transparent 0, transparent 2em, #58a 0, #58a 3em, transparent 0, transparent 4em) 16;
The effect is as follows:
Footer Effect
Because currentColor is used, it automatically adapts to changes in the color attribute.
padding-top:1em; border-top: .2em solid transparent; border-image: 100% 0 0 linear-gradient(90deg,currentColor 4em,transparent 0);
Ant line
@keyframes ants{100%{background-position:100%;}}div{ width:200px; height: 70px; border: 1px solid transparent; background: linear-gradient(white,white) padding-box,repeating-linear-gradient(-45deg, black 0, black 25%, white 0, white 50%) 0/.6em .6em; animation:ants 12s linear infinite;}