简体   繁体   English

带iframe的Div(隐藏并显示iframe)

[英]Div with Iframe (hiding and showing the iframe)

What i would like to do is this: 我想做的是这样的:

In my website, i want to have a div in the left corner that, when the mouse is NOT over it, its just a simple square with a color (for now). 在我的网站中,我想在左上角有一个div,当鼠标不在其上方时,它只是一个带有颜色的简单正方形(目前)。

For that, i have this code: 为此,我有以下代码:

<div id='bot'>
</div>

Its very simple of course, in my css: 当然,在我的CSS中非常简单:

#bot{
  position: fixed !important;
  bottom: 40px !important;
  width:50px;
  height:150px;
  left:0%;
  border:1px solid black;
  box-shadow:1px 1px 1px;
}

#bot:hover{
  width:500px;
}

Ok so for now this does it. 好的,现在就可以了。 Now what i would like to appear on this div when i MOUSEOVERIT, would be it show a iframe: 现在,当我使用MOUSEOVERIT时,我想在此div上显示的是iframe:

<iframe name='botframe' src='http://demo.vhost.pandorabots.com/pandora/talk?botid=a431414a6e34774c' frameborder='0' scrolling='no'></iframe>

Is this possible at all? 这有可能吗? If so, what would i have to do? 如果是这样,我该怎么办? I understand a bit of javascript if needed, but no so much of jQuery, so if jQuery is needed please tell me exactly what i must do and where to put the code. 如果需要,我会了解一些javascript,但是不需要jQuery,因此,如果需要jQuery,请确切地告诉我我必须做什么以及将代码放置在何处。

Thank you so much in advance 提前谢谢你

Instead of using id for div pls put id for iframe, 而不是将ID用于div pls,而将ID用于iframe,

<div> <iframe **id='bot'** name='botframe' src='http://demo.vhost.pandorabots.com/pandora/talk?botid=a431414a6e34774c' frameborder='0' scrolling='no'></iframe>
</div>

Lay the div over the iframe, and change the z-index of each on hover. 将div放在iframe上,并在悬停时更改每个div的z索引。

<iframe id='botframe' name='botframe' src='http://placehold.it/50/' frameborder='0' scrolling='no'></iframe>
<div id='bot'></div>

#bot{position:fixed; background:pink; bottom:40px; width:50px; height:150px; left:0; border:1px solid black;}
#botframe {position:fixed; background:yellow; bottom:40px; width:50px; height:150px; left:0; border:1px solid red;}
#bot:hover{z-index:-1;}
#botframe:hover{z-index:100;}

http://jsfiddle.net/gcWeC/ http://jsfiddle.net/gcWeC/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM