I'm

Developer, Designer, Photographer

GET IN TOUCH

  • Buk-gu, Busan, Republic of Korea
  • ungdoli0916@naver.com
  • Kakao ID : Ungdoli
Your message has been sent. Thank you!
(즐거웅코드) svg로 중간에 마스크 씌워진 삼각형 그리기

· 즐거'웅' 코드 (Source)/HTML & CSS & JAVASCRIPT
2021. 6. 6. 23:00

반응형

[즐거'웅'코드] 목차

  1. 예제 소스
  2. 구현 예시
예제 소스
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<svg x="0" y="0" width="100%" height="100%" viewBox="0 0 100 100" preserveAspectRatio="none">
    <defs>
        <mask id="masking">
            <rect width="100%" height="100%" fill="white"/>
            <rect x="0" y="40%" width="100%" height="20%" fill="#000000"/>
        </mask>
    </defs>
    <g mask="url(#masking)">
        <polygon id="triangle" fill="none" stroke="#000000" stroke-opacity="1" stroke-width="1" points="50, 0 0, 100 100, 100"/>
    </g>
</svg>
 
<style>
    #triangle{
        stroke-dasharray: 4000;
        animation: drawing 30s ease-out forwards;
    }
 
    @keyframes drawing {
        to {
            stroke-dashoffset: 0;
        }
        from {
            stroke-dashoffset: 4000;
        }
    }
</style>
구현 예시
반응형