돌아가기
이 글은 다음 언어로만 작성되어 있습니다. عربي, English, Español, Français, Italiano, 日本語, Русский, Українська, 简体中文. 한국어 번역에 참여해주세요.

Show a note near the element (absolute)

중요도: 5

Modify the solution of the previous task so that the note uses position:absolute instead of position:fixed.

That will prevent its “runaway” from the element when the page scrolls.

Take the solution of that task as a starting point. To test the scroll, add the style <body style="height: 2000px">.

The solution is actually pretty simple:

  • Use position:absolute in CSS instead of position:fixed for .note.
  • Use the function getCoords() from the chapter 좌표 to get document-relative coordinates.

샌드박스를 열어 정답을 확인해보세요.