html & css

css) variable

tose33 2021. 8. 17. 17:38

https://www.w3schools.com/css/css3_variables.asp

 

CSS Variables - The var() function

CSS Variables - The var() Function CSS Variables The var() function is used to insert the value of a CSS variable. CSS variables have access to the DOM, which means that you can create variables with local or global scope, change the variables with JavaScr

www.w3schools.com

 

css의 value를 저장할수 있다.

 

 

scope

variable의 범위는 local 또는 global이다.

 

global vaiable을 선언하기 위해서는 :root selector에 variable을 정의하면된다.

variable을 정의할때는 앞에 -- 를 붙인다.

variable을 사용할때는 var(변수명)으로 사용한다. 

 

local variable은 그냥 사용할 해당 selector 내부에서 정의해주면된다.

 


다음과 같이 transition의 value들도 저장해 놓을수 있다.