[英]Is it possible to make a div follow another element iside an iframe if the content of the iframe is from the same domain
我正在考慮使用JavaScript在父網頁中創建一個div,以跟隨iframe中另一個元素的位置; 當窗口的大小更改時(響應式設計),iframe中元素的位置也會更改,因此是否也可以使父頁面上的div也相應地更改? 我根本不知道從哪里開始
您可以在iframe中獲取該元素:
document.getElementById('iFrame').contentWindow.document.getElementById('x');
一旦獲得元素,就可以使用他的位置,要使用純JavaScript獲取元素位置,請看this 。
使用jquery進行此操作更簡單,但使用javascript可能更有效。
畢竟,只需根據元素的位置定位div。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.