2021. 8. 31. 13:55ใCSS
๊ฒฐ ๋ก
::-webkit-scrollbar {
height: 0px;
width: 5px;
}
::-webkit-scrollbar-thumb {
background-color: rgb(170, 165, 165);
border-radius: 30px;
}
๐ Safari / Chrome ํ๊ฒฝ์์ ๋์ํ๋ ์คํฌ๋กค์ ::-webkit-scrollbar ์ ์ด์ฉํด CSS ์กฐ์ ์ด ๊ฐ๋ฅํ๋ค.
์ฌ์ง์ CSS๋ฅผ ์ ์ฉํ์ง ์์ ๊ธฐ๋ณธ ์คํฌ๋กค๋ฐ ํ๋ฉด์ผ๋ก, ๊ฐ๋จํ css ์ ์ฉ์ ํตํด ๋ ์ฌ์ด๋ก ๊ฑฐ๋ญ๋ ์ ์๋ค.

Result
See the Pen by wkddkdud (@angpeng) on CodePen.
1. ::-webkit-scrollbar _ ์คํฌ๋กค๋ฐ ์ ์ฒด ์์ญ ์กฐ์
::-webkit-scrollbar {
height: 0px; /* x์ถ ์คํฌ๋กค */
width: 5px; /* y์ถ ์คํฌ๋กค */
box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.2);
}
height์ ํตํด x์ถ์ ๊ฐ๋ก ์คํฌ๋กค & width๋ฅผ ํตํด y์ถ์ ์ธ๋ก ์คํฌ๋กค์ ์กฐ์ ํ ์ ์์ผ๋ฉฐ,
height์ 0์ผ๋ก ์ง์ ํ ๊ฒฝ์ฐ x์ถ์ overflow๊ฐ ๋ฐ์ํด๋ ์คํฌ๋กค ๋ณด์ด์ง ์์ ๊น๋ํ ํ๋ฉด์ด ๊ฐ๋ฅํ๋ค. (๋ ๋ง์น ์นด๋ฉ๋ ์จ)
backgound ๋ box-shawdow์ ์์ฑํ ๊ฒฝ์ฐ ์คํฌ๋กค์ ์์์ด ์ ์ฉ๋๋ค. ์์ฑํ์ง ์์ ๊ฒฝ์ฐ ๊ธฐ๋ณธ ๋ฐฐ๊ฒฝ์์ ํฐ์์ด๋ค.
2. ::-webkit-scrollbar-thumb _ ์คํฌ๋กค ์์ฑ๋๋ ์์ญ
::-webkit-scrollbar { // ์คํฌ๋กค๋ฐ ์์ฒด ์์ญ
height: 0px;
width: 5px;
}
::-webkit-scrollbar-thumb { /* ์คํฌ๋กค ์์ญ */
background-color: rgb(170, 165, 165); /* ์คํฌ๋กค ์์ต ์์ ์กฐ์ */
border-radius: 30px; /* ์คํฌ๋กค ๋ง๋จ radius ์กฐ์ */
}
์คํฌ๋กค ์์ญ์ ํ์ธํ ์ ์๊ฒ ์คํฌ๋กค ์์ญ์ ์์( background-color )์ ์ ์ฉํ๊ณ ,
๋ฑ๋ฑํด ๋ณด์ด์ง ์๊ฒ ์คํฌ๋กค ๋ง๋จ์ border์ ๊ฐ๋๋ฅผ ์กฐ์ ํด ๋ฅ๊ธ๋ฅ๊ธํ ๋๋์ ๋ํด์ค๋ค.
์ด ์ธ์๋ ๋ค์ํ css ์์ฑ์ด ์กด์ฌํ๋ค.
3. ::-webkit-scrollbar-track _ ์คํฌ๋กค ์์ญ ์ ์ธ ๋ถ๋ถ
::-webkit-scrollbar {
height: 0px;
width: 5px;
background-color:red;
}
::-webkit-scrollbar-thumb {
background-color: rgb(170, 165, 165);
border-radius: 30px;
}
::-webkit-scrollbar-track{
background-color:blue
}
4. ::-webkit-scrollbar-button: start:decrement & end:increment _ ์คํฌ๋กค ์ํ ์ด๋ ๋ฒํผ ์์ญ
::-webkit-scrollbar-button:start:decrement,
::-webkit-scrollbar-button:end:increment {
height:40px;
background-color: white;
}
5. ::-webkit-scrollbar-corner _ x์ถ & y์ถ ์คํฌ๋กค ์ ์ ๋ถ๋ถ
::-webkit-scrollbar-corner {
background-color: yellow;
}