经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » HTML/CSS » CSS » 查看文章
css瀹炵幇鏂囧瓧鏂鏁堟灉鐨勭ず渚嬩唬鐮乢CSS鏁欑▼_CSS
来源:jb51  时间:2022/5/9 9:44:46  对本文有异议

clip-path灞炴€?/h3>

鍒涘缓涓€涓彧鏈夊厓绱犵殑閮ㄥ垎鍖哄煙锛屽彲浠ユ樉绀虹殑鍓垏鍖哄煙銆傚尯鍩熷唴鐨勯儴鍒嗘樉绀猴紝鍖哄煙澶栫殑闅愯棌銆?/p>

<h1 data-text="Text Crack">
    <span>Text Crack</span>
</h1>

浣跨敤鍏冪礌鐨勪吉鍏冪礌澶嶅埗涓や唤鏂囨湰锛屽啀浣跨敤 clip-path 灏嗗厓绱犳湰韬€佸厓绱犵殑涓や釜浼厓绱犲垎涓?閮ㄥ垎锛屽垎鍒杩?閮ㄥ垎杩涜鎺у埗

body, html
{
    display: flex;
    height: 100%;
    width: 100%;
    background-color: #000;
    overflow: hidden;
    font-family: sans-serif;
}
 
h1 {
    position: relative;
    margin: auto;
    font-size: calc(20px + 5vw);
    font-weight: bold;
    color: #fff;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    text-shadow: 0 0 10px blue;
    user-select: none;
    white-space: nowrap;
    filter: blur(0.007em);
    animation: shake 2.5s linear forwards;
}
 
h1 span {
    position: absolute;
    top: 0;
    left: 0;
    transform: translate(-50%, -50%);
    clip-path: polygon(10% 0%, 44% 0%, 70% 100%, 55% 100%);
}
 
h1::before,
h1::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
}
 
h1::before {
    animation: crack1 2.5s linear forwards;
    clip-path: polygon(0% 0%, 10% 0%, 55% 100%, 0% 100%);
}
 
h1::after {
    animation: crack2 2.5s linear forwards;
    clip-path: polygon(44% 0%, 100% 0%, 100% 100%, 70% 100%);
}
 
@keyframes shake {
    5%,
    15%,
    25%,
    35%,
    55%,
    65%,
    75%,
    95% {
        filter: blur(0.018em);
        transform: translateY(0.018em) rotate(0deg);
    }
 
    10%,
    30%,
    40%,
    50%,
    70%,
    80%,
    90% {
        filter: blur(0.01em);
        transform: translateY(-0.018em) rotate(0deg);
    }
 
    20%,
    60% {
        filter: blur(0.03em);
        transform: translate(-0.018em, 0.018em) rotate(0deg);
    }
 
    45%,
    85% {
        filter: blur(0.03em);
        transform: translate(0.018em, -0.018em) rotate(0deg);
    }
 
    100% {
        filter: blur(0.007em);
        transform: translate(0) rotate(-0.5deg);
    }
}
 
@keyframes crack1 {
    0%,
    95% {
        transform: translate(-50%, -50%);
    }
 
    100% {
        transform: translate(-51%, -48%);
    }
}
 
@keyframes crack2 {
    0%,
    95% {
        transform: translate(-50%, -50%);
    }
 
    100% {
        transform: translate(-49%, -53%);
    }
}

鍥犱负浣跨敤浜?clip-path 瑁佸壀鍚庣殑鍏冪礌锛屽彧鏈夊厓绱犵殑鍓垏鍖哄煙鎵嶈兘琚樉绀猴紝鎵€浠ユ垜浠彲浠ュ垎鍒帶鍒?3 涓儴鍒嗚繘琛屽姩鐢?/p>

鏈€缁堟晥鏋滃涓?/p>

鍒版杩欑瘒鍏充簬css瀹炵幇鏂囧瓧鏂鏁堟灉鐨勭ず渚嬩唬鐮佺殑鏂囩珷灏变粙缁嶅埌杩欎簡,鏇村鐩稿叧css 鏂囧瓧鏂鍐呭璇锋悳绱㈣剼鏈箣瀹朵互鍓嶇殑鏂囩珷鎴栫户缁祻瑙堜笅闈㈢殑鐩稿叧鏂囩珷锛屽笇鏈涘ぇ瀹朵互鍚庡澶氭敮鎸佽剼鏈箣瀹讹紒

 友情链接: NPS