Home  >  Article  >  Web Front-end  >  DIV怎么相对顶层框架定位?_html/css_WEB-ITnose

DIV怎么相对顶层框架定位?_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:17:141210browse

有这样一个页面,页面包含三个框架:


  
  
  

在frame3中有一个div,如何才能让div相对name="test"的frameset绝对定位,而不是相对frame3定位?

回复讨论(解决方案)

frameset position:relative
frame3 position:static
div position:absolute

绝对定位的元素的位置相对于最近的已定位祖先元素,如果元素没有已定位的祖先元素,那么它的位置相对于最初的包含块。

参考:
http://w3school.com.cn/css/css_positioning_absolute.asp
http://w3school.com.cn/css/pr_class_position.asp

经测试,#1楼的方法行不通。定位属性一般只相对于当前window,而在框架里面,每一个frame都对应一个window。

貌似FRAMESET现在都不用了,很多浏览器都不支持了,建议换成Iframe

frameset不行,无法跨框架。

按照#3的修改,3个布局用iframe来实现,然后div放父页,这样就可以相对那个定位都行了

经测试,#1楼的方法行不通。定位属性一般只相对于当前window,而在框架里面,每一个frame都对应一个window。
噢噢不好意思未经测试就发出来了,见笑 = =

貌似FRAMESET现在都不用了,很多浏览器都不支持了,建议换成Iframe
这个是几年前的项目,没办法,现在在改,而框架不能动。你说的这种方案我也了解,还是谢谢了!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn