UI Components์ถ์ฒ: CSS-Tricks์กฐํ์ 8
Potentially Coming to a Browserย :near()ย You
By Daniel Schwarz2026๋
2์ 21์ผ
**Potentially Coming to a Browserย :near()ย You**
Just before we wrapped up 2025, I saw this proposal for :near(), a pseudo-class that would match if the pointer were to go near the element. Well, that would depend on the value of the <length> argument provided. Thomas Walichiewicz, who proposed :near(), suggests that it works like this: button:near(3rem) { /* Pointer is within 3rem of the button */ } For those wondering, yes, we can use the Pythagorean theorem to measure the straight-line distance between two elements using JavaScript (โEuclidean distanceโ is the mathematical term), so I imagine that thatโs what would be used behind the scenes here. I have some use cases to share with you, but the demos will only be simulating :near() since itโs obviously not supported in any web browser. Visual effects Without question, :near() could be used for a near-infinite (sorry) number of visual effects: div { /* Div is wow */ &:near(3rem) { /* Div be wowzer */ } &:near(1rem) { /* Div be woahhhh */ } } Dim elements until :near() To reduce visual clutter, you might want to dim certain components until users are near them...
---
**[devsupporter ํด์ค]**
์ด ๊ธฐ์ฌ๋ CSS-Tricks์์ ์ ๊ณตํ๋ ์ต์ ๊ฐ๋ฐ ๋ํฅ์ ๋๋ค. ๊ด๋ จ ๋๊ตฌ๋ ๊ธฐ์ ์ ๋ํด ๋ ์์๋ณด์๋ ค๋ฉด ์๋ณธ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ์ธ์.
Just before we wrapped up 2025, I saw this proposal for :near(), a pseudo-class that would match if the pointer were to go near the element. Well, that would depend on the value of the <length> argument provided. Thomas Walichiewicz, who proposed :near(), suggests that it works like this: button:near(3rem) { /* Pointer is within 3rem of the button */ } For those wondering, yes, we can use the Pythagorean theorem to measure the straight-line distance between two elements using JavaScript (โEuclidean distanceโ is the mathematical term), so I imagine that thatโs what would be used behind the scenes here. I have some use cases to share with you, but the demos will only be simulating :near() since itโs obviously not supported in any web browser. Visual effects Without question, :near() could be used for a near-infinite (sorry) number of visual effects: div { /* Div is wow */ &:near(3rem) { /* Div be wowzer */ } &:near(1rem) { /* Div be woahhhh */ } } Dim elements until :near() To reduce visual clutter, you might want to dim certain components until users are near them...
---
**[devsupporter ํด์ค]**
์ด ๊ธฐ์ฌ๋ CSS-Tricks์์ ์ ๊ณตํ๋ ์ต์ ๊ฐ๋ฐ ๋ํฅ์ ๋๋ค. ๊ด๋ จ ๋๊ตฌ๋ ๊ธฐ์ ์ ๋ํด ๋ ์์๋ณด์๋ ค๋ฉด ์๋ณธ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ์ธ์.
