일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 28 | 29 | 30 |
- NextJs
- HTML
- heroku
- API
- CSS
- JavaScript
- TypeScript
- 자바스크립트
- clonecoding
- GRID
- form
- MongoDB
- graphQL
- express
- ECMAScript
- nodejs
- frontend
- javscript
- react
- backend
- CLONE
- pug
- ES6
- DART
- 리액트
- node.js
- Component
- Mongoose
- Flutter
- Session
- Today
- Total
Enjoy Programming
css에서 전역변수 본문
먼저 컬러를 보자color는 시스템이 있다
1. 16진수 컬러(hexadecimal color)
#000000
2. RGB 컬러(이걸 많이 알고있다.. opencv에서는 bgr... )
rgb(0, 0, 0) 각 값은 255가 최대 값. 0에 가까울수록 검은색.
rgb(0, 0, 0, alpha) - alpha는 opacity(투명도) 4채널
이러한 컬러를 여러곳을 변경해야 할때 여기저기 다 고치기는 번거롭다.
이때 변수를 선언해주는데
ex>
:root 를 이용하자 - 전역 변수를 선언해서 코드를 편하게 짜기

:root{ --main-color : color } 를 통해 일정 색을 전역변수에 담고 내가 스타일링 해줘야 할곳에 변수만 집어 넣으면 된다.
so~~ easy ~ 차후 색상을 변경할때 간편해진다.
색상만 되는게 아니고
--pane-paddin: px px;
--default-border: px line var(--main-color); *이건 보더에 이미 설정한 메인 컬러도 넣어준거...
이런 것도 된다.
developer.mozilla.org/en-US/docs/Web/CSS/--*
Custom properties (--*): CSS variables - CSS: Cascading Style Sheets | MDN
Custom properties (--*): CSS variables Property names that are prefixed with --, like --example-name, represent custom properties that contain a value that can be used in other declarations using the var() function. Custom properties are scoped to the el
developer.mozilla.org
적용은 익스플로러 빼고 다된다.. 익스....
'CSS' 카테고리의 다른 글
Transformation (0) | 2021.03.25 |
---|---|
Transitions (0) | 2021.03.25 |
:: selector (pseudo selectors) (0) | 2021.03.25 |
states (pseudo selecotrs) (0) | 2021.03.25 |
attribute selectors (0) | 2021.03.25 |