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

var() CSS 함수 사용

<시간/>

CSS의 var() 함수는 웹 페이지에 사용자 정의 속성 값을 추가하는 데 사용됩니다. 속성의 사용자 정의 이름을 설정하고 값을 설정합니다.

예시

var() 함수를 구현하기 위해 다음 코드를 실행할 수 있습니다.

<!DOCTYPE html>
<html>
   <head>
      <style>
         :root {
            --my-bg-color: blue;
            --my-color: white;
         }
         #demo {
            background-color: var(--my-bg-color);
            color: var(--my-color);
         }
      </style>
   </head>
   <body>
      <h1>Heading One</h1>
      <div id = "demo">
         This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text.
      </div>
      <br>
   </body>
</html>