CSS cold knowledge scenario

Time:2022-5-19

inherit

Specifies that an attribute should inherit its value from the parent element

div{
    color:#fff000
}
div>a{
    color:inherit
}

background-clip

background-clip: border-box|padding-box|content-box

Border box defaults. The background is drawn inside the border box (cut into a border box).
The padding box background is drawn inside the padding box (cut into a padding box).
The content box background is drawn in the content box (cut into content box).

Solve the translucent border, which is covered by the background picture

div{
    width:100px;
    height:100px;
    background:rgb(255,240,0,1);
    border:10px solid rgb(255,240,0,0.5);
    background-clip: padding-box;
 }

box-shadow

box-shadow: h-shadow v-shadow blur spread color inset

_ h-shadow_: Required. The location of the horizontal shadow. Allow negative values
_ v-shadow_: Required. The position of the vertical shadow. Allow negative values
_ blur_: Optional. Fuzzy distance
_ spread_: Optional. Shadow size
_ color_: Optional. The color of the shadow.
Inset: optional. Change the shadow from the outer shadow (at the beginning) to the inner shadow

Shadow Complex

div{
    width:100px;
    height:100px;
    border-radius: 50%;
    box-shadow: 10px 10px 0px 10px red, 20px 20px 0px 20px blue, 30px 30px 0px 30px yellow, 40px 40px 0px 40px green;
    margin:auto;
    margin-top:200px;
 }

outline

outline: outline-color outline-style outline-width
A line drawn around an element on the periphery of the border edge to highlight the element

_ outline-color_: Specifies the color of the border
_ outline-style_: Specifies the style of the border
_ outline-width_: Specifies the width of the border

Double border, usually a solid line border on the outside and a dot border on the inside

div{
    width:100px;
    height:100px;
    border:5px solid red;
    outline: 1px dashed red;
    outline-offset: -10px;
 }

Double border, usually solid line border on the outside and rounded border on the inside

div{
    width:100px;
    height:100px;
    border:2px solid red;
    border-radius: 10px;
    outline: 6px solid red;
    box-shadow: 0 0 0 4px red;
 }

CSS cold knowledge scenario

clip-path

circle|ellipse|polygon

Circle: circle
Ellipse: (the x-axis radius of the ellipse, the y-axis radius of the ellipse at the center of the ellipse)
Polygon: (top, right, bottom, left) each point is composed of X direction and Y direction

Parallelogram and diamond

.diamond>div{
    width: 150px;
    height:70px;
    color: white;
    justify-content: center;
    align-items: center;
    position: relative;
}
.diamond>div:nth-of-type(1)::before{
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    z-index: -1;
    transform: skewX(-45deg);
    background: #b4a078;
}
.diamond>div:nth-of-type(2){
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
    transition: 1s clip-path;
    background: #b4a078;
}
.diamond>div:nth-of-type(2):hover{
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

CSS cold knowledge scenario

progress bar

.outer{
    width:60%;
    height:20px;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
 }
 .enter{
    height:inherit;
    background:rgba(180, 160, 120, .2);
 }
 .bg{
    width:60%;
    height: inherit;
    border-radius: 8px;
    background: repeating-linear-gradient(-45deg, #D9CFBB  25%, #C3B393 0, #C3B393 50%,
            #D9CFBB 0, #D9CFBB 75%, #C3B393 0);
    background-size:20px 20px;
    animation: panoramic 20s linear infinite;
 }
 @keyframes panoramic{
    to{
        background-position: 200% 0;
    }
 }

CSS cold knowledge scenario

Irregular card

div{
    width: 200px;
    height: 120px;
    background-image: radial-gradient(circle at 100px -8px, transparent 20px, #b4a078 21px);
 }

CSS cold knowledge scenario