[英]I can't figure out how to make my iFrame drop-down on click
So I managed to get my iFrame to drop-down on hover, but it closes when the cursor moves out of the frame, or moves outside of the hyperlink in IE 9. I'd like to keep it open until I click somewhere else on the page. 因此,我设法将iFrame悬停在下拉菜单上,但是当光标移出框架或在IE 9中移至超链接之外时,它会关闭。我想一直保持打开状态,直到单击其他位置这一页。 So unless there's a way to keep it from closing on hover, I'd like to change it to a onclick event.
因此,除非有一种方法可以防止它在悬停时关闭,否则我想将其更改为onclick事件。 Here's the code:
这是代码:
HTML: HTML:
<li><a href="#" id="uploadFiles">Upload files</a>
<div id="stf" sty><!-- SendThisFile FileBox v3.02 (www.24-7transcripts.com) -->
<table cellspacing=0 cellpadding=3 style="font-family: verdana, arial; font-size: 10px;">
<tr><td align="center"><iframe id="stfLink" src="https://www.sendthisfile.com/filebox/index.jsp?widgetcode="ijljoo890jfljou98" marginwidth=0 marginheight=0 width="350" height="400" scrolling="no" frameborder=0></iframe></td></tr>
<tr><td align="center"></td></tr>
</table>
<!-- SendThisFile FileBox v3.02 --></div>
</li>
CSS: CSS:
.headerNav li #uploadFiles {
color: #CCC;
padding-top: 10px;
font-size: 14px;
float: right;
padding-right: 20px;
text-align: right;
}
.headerNav li {
-webkit-transition: all 0.5s ease-out;
}
.headerNav li #stf {
margin-right: -10px;
display: none;
height: 0px;
-webkit-transition: all 0.5s ease-out;
}
.headerNav li:hover #stf {
margin-right: -80px;
display: block;
float: right;
margin-top: 25px;
border-radius: 10px;
}
Is there a property I'm missing in the CSS? CSS中缺少我缺少的属性吗? Or is there a way to do this with Javascript that I can't seem to find anywhere?
还是有一种方法可以用我似乎在任何地方都找不到的Javascript做到这一点?
Because the style is applied on :hover
, and the element loses that pseudo-selector on the mouseout event, the behaviour you describe is expected. 因为样式应用于
:hover
,并且元素在mouseout事件上丢失了该伪选择器,所以预期您所描述的行为。
You can't use a pseudo-selector for click events. 您不能将伪选择器用于点击事件。 You'll have to use JavaScript to add a class on click and remove it on another event.
您必须使用JavaScript在单击时添加一个类,并在另一个事件上将其删除。
In jQuery it would look something like: 在jQuery中,它看起来像:
$('#myNavItem').click(function() {
$('#myIFrame').addClass('.expanded');
});
You'll also have to change your CSS :hover
selector to be .expanded
. 您还必须将CSS
:hover
选择器更改为.expanded
。 It will observe the same CSS3 transitions on this event. 它将在此事件上观察到相同的CSS3过渡。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.