2019/08/29 TIL(Today I Learn)
- August 29, 2019
- 2 minute read
์ธ์
-
CSS = Cascading Style Sheets
- ์น ํ์ด์ง ๊ตฌ์ฑ์์์ ์คํ์ผ์ ์ ์ํ๋ ์ธ์ด. ์ค๋๋ ๋ช ์นญ๊ณผ ์ ์๋ถํฐ ํ์ต :)
-
left:0; right:0;
- ์ข์ฐ๋ก 100% ์คํธ๋ ์น๋๊ฒ ๋ง๋ ๋ค.
- top / bottom ์์น์ position: fixed ์ค์ ํด์ ํ๋กํ ์์๋ก ๋ง๋ค ์ ์๋ค.
- ์ธ๋ผ์ธ ์์๋ position: absolute / fixed์์๋ง ์ข์ฐ๋ก ์คํธ๋ ์น ๋๋ค.
-
{ box-sizing: border-box; }
- ์์์ ์ค์ ํฌ๊ธฐ๋ width, height ๊ฐ์ padding๊ณผ border ๊ตต๊ธฐ ๊ฐ์ ๋ํ ๊ฐ์ด ๋์ด๋ฒ๋ ค ์ํ๋ ํฌ๊ธฐ๋ฅผ ๋ง๋ค๊ธฐ๊ฐ ์ด๋ ค์ด๋ฐ, ์ด๋ฅผ ํด๊ฒฐํด์ฃผ๋ ์์ฑ.
- padding์ border ๊ตต๊ธฐ ๊ฐ์ด ํฌํจ๋์ด ์ง์ ํ width, heigth ๊ฐ์ผ๋ก ํฌ๊ธฐ๊ฐ ๋ฑ ๋ง๋ค์ด์ง๋ค.
- ์ฌํ๋ฆฌ, ํฌ๋กฌ, ํ์ด์ดํญ์ค์ ์์ ๊ตฌ ๋ฒ์ ์์๋ ์๋์ฒ๋ผ ์ ๋์ฌ๋ฅผ ๋ถ์ด์ฃผ์ด์ผํ๋ค.
-moz-box-sizing: border-box; /* ํ์ด์ดํญ์ค(Firefox)*/
-webkit-box-sizing: border-box; /* ์นํท(Webkit) & ํฌ๋กฌ(Chrome) */
- https://caniuse.com/#search=border-box
-
position: sticky
- ์์๊ณผ ํ๋ฉด ์๋จ์ ๋ฟ์๋งํผ ์คํฌ๋กค๋๋ฉด, ๊ทธ ์์น fixed ์์ฑ ๊ฐ์ฒ๋ผ ๊ณ ์ ๋๋ค.
- https://caniuse.com/#search=position%3A%20sticky
Q&A
- HTML ์์ค ์์์ onClick ๋ฑ์ ์์ฑ์ ์ฌ์ฉํ๊ธฐ ๋ณด๋ค, ์๋ฐ ์คํฌ๋ฆฝํธ์์ ์ด๋ฒคํธ๋ฅผ ์ถ๊ฐํด์ฃผ๋ ๊ฑธ ์ถ์ฒ.
-
์ง์ญ ํจ์์๋ ์ ๊ทผํ ์ ์๊ณ , HTML ์์ค ์์๋ ํจ์ ๋ช ์ด ๋ ธ์ถ๋๋ค.
- ์ด๋ฒคํธ๋ฅผ ์ถ๊ฐํ๋ ๋ฐฉ์์ผ๋ก ์ด๋ฒคํธ ๋ฆฌ์ค๋ ์ถ๊ฐ ์ธ์ ๊ธ๋ก๋ฒ ์ด๋ฒคํธ ํธ๋ค๋ฌ๋ ์์๋ค.
- Syntax:
๋ณ์.onclick = function() { โฆ };
ORfunctionRef;
- https://developer.mozilla.org/ko/docs/Web/API/GlobalEventHandlers
Hoisting
- ์ ์ญํจ์ / ์ง์ญํจ์์ ๋ํด ๋ ์ดํดํ๋ ค๊ณ ๊ฒ์ํ๋ ์ค ํธ์ด์คํ (Hoisting)์ด๋ผ๋ ๊ฐ๋ ์ ๋ณด๊ฒ ๋๋ค.
-
https://aspdotnet.tistory.com/2106
function abc(){ var a = 'bbb'; console.log(a); // bbb function c(){ console.log(a); // undefined (function(){ console.log(a); // undefined a = 'ccc'; })(); var a; //------ function c scope ๋ณ์ ํ ์ด๋ธ ์์ a ์ ์ธ console.log(a); // ccc } function d(){ console.log(a); // ddd ----- ๊ฐ์ฅ ๊ฐ๊น์ด ๋ณ์ ํ ์ด๋ธ์ธ 2๋ฒ ์งธ ์ค์์ ์ ์ธ๋ aaa๋ฅผ ์ฐธ์กฐํจ } c(); a = 'ddd'; d(); } abc();
- ๋ณ์ ํ ์ด๋ธ์ด๋ผ๋ ๊ฐ๋ ์ ์ฒ์ ์๊ฒ ๋๋ค. ํจ์ c ์์ 1, 2 ๋ฒ์งธ a๋ undefined๊ณ d์ a๋ ๋ถ๋ชจ ํจ์์ ๊ฐ์ ๊ฐ์ ธ์ค๋ ๊ฒ ์ฌ๋ญ ์ดํด๊ฐ ์๋๋๋ฐ, ๋๊ธ์๋ ๊ฐ์ ๋ด์ฉ์ด ์์๋ค. ๋ง์์ผ๋ก๋ ๋ฐ์๋ค์ผ ์ ์๋ ํ๋ฆ์ด์ง๋ง ๋จธ๋ฆฌ๋ก๋ ์ดํดํด๋ณธ๋ค. ใ ใ ใ