Computer >> 컴퓨터 >  >> 프로그램 작성 >> CSS

CSS 클립 경로를 사용하여 삼각형을 만드는 방법

<시간/>

CSS 클립 경로 속성을 사용하여 삼각형을 만들 수 있습니다.

구문

CSS 클립 경로 속성의 구문은 다음과 같습니다 -

Selector {
   clip-path: /*value*/
}

예시

다음 예는 CSS 클립 경로 속성을 보여줍니다.

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            padding: 10%;
            border-radius: 2%;
            width: 10%;
            box-shadow: inset 0 0 80px violet;
            clip-path: polygon(50% 0, 100% 100%, 0% 100%);
         }
      </style>
   </head>
   <body>
      <div></div>
   </body>
</html>

이것은 다음과 같은 출력을 제공합니다.

CSS 클립 경로를 사용하여 삼각형을 만드는 방법

예시

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            display: flex;
            margin: 10px 0 20px;
         }
         div > div {
            height: 12px;
            border-top: 40px ridge orange;
            border-right: 20px solid white;
            border-bottom: 60px ridge cornflowerblue;
            border-left: 80px solid white;
         }
      </style>
   </head>
   <body>
      <div>
         <div></div>
      </div>
   </body>
</html>

이것은 다음과 같은 출력을 제공합니다.

CSS 클립 경로를 사용하여 삼각형을 만드는 방법