일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
31 |
Tags
- 호이스팅
- ESlint
- 인터섹션
- TS
- tailwind
- 투포인터
- 태그된 유니온
- RTK Query
- CORS
- 공변성
- Promise
- 타입 좁히기
- MSA
- React
- async/await
- map
- Jest
- useAppDispatch
- webpack
- autosize
- recoil
- app router
- 무한 스크롤
- 반공변성
- SSR
- 인증/인가
- CI/CD
- 리터럴 타입
- dfs
- 결정 알고리즘
Archives
- Today
- Total
짧은코딩
챌린지 11일차 본문
반응형
const colors = [
"#ef5777",
"#575fcf",
"#4bcffa",
"#34e7e4",
"#0be881",
"#f53b57",
"#3c40c6",
"#0fbcf9",
"#00d8d6",
"#05c46b",
"#ffc048",
"#ffdd59",
"#ff5e57",
"#d2dae2",
"#485460",
"#ffa801",
"#ffd32a",
"#ff3f34"
];
const Btn = document.querySelector("button");
function BackChange() {
const Random1 = colors[Math.floor(Math.random() * colors.length)];
const Random2 = colors[Math.floor(Math.random() * colors.length)];
const col = `linear-gradient(to right, ${Random1}, ${Random2})`;
document.body.style.background = col;
}
Btn.addEventListener("click", BackChange);
linear-gradient를 사용하면 2가지 색을 같이 사용할 수 있다는 것을 알게되었다.
그리고 배경색을 바꾸려면 backgroundcolor로 하면 안된다. 대신 background나 backgroundImage로 해야 배경색이 바뀐다는 것을 알았다.
반응형
'노마드 코더 > 바닐라 JS로 크롬 앱 만들기' 카테고리의 다른 글
마지막 챌린지 완성본 (2) | 2022.05.21 |
---|---|
마지막 챌린지(만든지 첫 날) (0) | 2022.05.20 |
챌린지 10일차 (0) | 2022.05.18 |
챌린지 8일차 (0) | 2022.05.16 |
챌린지 5일차 (0) | 2022.05.13 |
Comments