返回課程

將註解定位在內部 (絕對)

重要性:5

延伸前一個任務 在元素附近顯示註解 (絕對):教授函式 positionAt(anchor, position, elem) 以將 elem 插入到 anchor 內部。

position 的新值

  • top-outright-outbottom-out – 與之前相同,它們將 elem 插入到 anchor 的上方/右側/下方。
  • top-inright-inbottom-in – 將 elem 插入到 anchor 內部:將其貼到上/右/下邊緣。

例如

// shows the note above blockquote
positionAt(blockquote, "top-out", note);

// shows the note inside blockquote, at the top
positionAt(blockquote, "top-in", note);

結果

將任務 在元素附近顯示註解 (絕對) 的解答作為原始碼。