CSS Variables Tutorial

· 6년 전 · 1046

 

1. What are CSS varaiables?

 

자주 쓰는 색상같은것을 미리 CSS변수로 정해서 사용할려고 함.

CSS Variables == Custom Properties 라고 함.

--my-property: value;     --를 앞에 붙여서 만듬

 

https://github.com/iamshaunjp/CSS-Variables

 

 

2. Declaring Variables

태그안에 선언하면 그 안에만 적용?

전체에 적용할려면..

:root{}

 

:root{

  --theme-color: #3e84da;

  --link-color: #daa33e;

}

사용은

background: var(--theme-color);

color: var(--theme-color);

color: var(--link-color);

 

 

 

3. CSS Varable Benefis

 

--layout: 1fr 1fr 1fr;  으로 설정하고 아래와 같이 처리하면.. Responsive 처리가 가능함.

@media screen and (max-width: 760px){

  :root{

    --layout: 1fr;

  }

}

내비게이션 파트만 오버라이드..

nav{

  --link-color: #000;

}

 

 

4. CSS Variables & javascript

 

테마(색상) 선택을 변수와 Javascript로..

 

|
댓글을 작성하시려면 로그인이 필요합니다. 로그인

CSS

CSS 관련 공부 및 자료 공유 소모임 게시판 입니다.

+
제목 글쓴이 날짜 조회
6년 전 조회 942
6년 전 조회 1,127
6년 전 조회 1,011
6년 전 조회 1,333
6년 전 조회 1,837
6년 전 조회 1,295
6년 전 조회 1,217
6년 전 조회 1,491
6년 전 조회 1,355
6년 전 조회 1,027
6년 전 조회 1,485
6년 전 조회 880
6년 전 조회 816
6년 전 조회 765
6년 전 조회 1,047
6년 전 조회 992
6년 전 조회 938
6년 전 조회 979
6년 전 조회 1,009
6년 전 조회 887
6년 전 조회 1,097
6년 전 조회 986
6년 전 조회 668
6년 전 조회 948
6년 전 조회 978
6년 전 조회 875
6년 전 조회 746
6년 전 조회 721
6년 전 조회 998
6년 전 조회 953
🐛 버그신고