当前位置: 动力学知识库 > 问答 > 编程问答 >

php - How to position iframes

问题描述:

How do I position iframes? I have read that I should contain them within a div, but I can't seem to get that to work...

I want the iframes inside the divs so that I may only show a part of the original site on only a part of my site.

<style>

#s1 {

height:50%;

width:50%;

float:left;

}

#s2 {

height:50%;

width:50%;

float:right;

}

</style>

<body>

<div id="s1">

<iframe id="my-iframe" src="www.site1.com" scrolling="no" style="position:absolute; top:-150px; left:0px; border:none; margin:0; padding:0; overflow:hidden; z-index:999999; ">

</iframe>

</div>

<div id="s2">

<iframe id="my-iframe" src="www.site2.com" scrolling="no" style="position:absolute; top:0px; left:0px; border:none; margin:0; padding:0; overflow:hidden; z-index:999999; ">

</iframe>

</div>

</body>

网友答案:

The problem is you set float: left for parent then set position: absolute for iframe you should choose one of these, if you want to make iframes side by side with float so you don't need use absolute for childrens, remove inline css for iframes and use float for parents. if you want use position absolute then remove floats. if you want to use absolute position for children you should set position: relative for parent.

JSFiddle

分享给朋友:
您可能感兴趣的文章:
随机阅读: