UI Components์ถœ์ฒ˜: CSS-Tricks์กฐํšŒ์ˆ˜ 9

Potentially Coming to a Browserย :near()ย You

By Daniel Schwarz
2026๋…„ 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์—์„œ ์ œ๊ณตํ•˜๋Š” ์ตœ์‹  ๊ฐœ๋ฐœ ๋™ํ–ฅ์ž…๋‹ˆ๋‹ค. ๊ด€๋ จ ๋„๊ตฌ๋‚˜ ๊ธฐ์ˆ ์— ๋Œ€ํ•ด ๋” ์•Œ์•„๋ณด์‹œ๋ ค๋ฉด ์›๋ณธ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”.