willthiswork89
willthiswork89

Reputation: 617

Showing iframe on hover over text

I am trying to add an "additional information" style iframe when you hover over a particular area of text. With the help of some javascript and css and two divs in my basic setup.

<a 
   onmouseover="ShowContent('uniquename3'); return true;"
   onmouseout="HideContent('uniquename3'); return true;"
   href="javascript:ShowContent('uniquename3')">
Tournament 22:00-23:00
</a>
<div 
   id="uniquename3" 
   style="display:none; position:relative; left:0px; top:10px; border-style: none; background-color: gray; padding: 5px;overflow:none;width:212px;z-index:5;">
 <iframe src="Test2.html" width="212px" height="340px" border="0" scrollbar="no" frameborder="0"></iframe>
</div>
<div id="other" style="z-index:1;">
    Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque     laudantium,     totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae     dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit,     sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam     est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius     modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima     veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea     commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil     molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"
</div>

The problem i'm having is that my javascript positions the new div with the iframe where my mouse is, and then bumps all of my text around. Really what I need to do is have the iframe show up but not mess with the elements around it. Currently when you would hover over the anchor it will bump all the lorem ipsum down by the length of the div with the iframe in it. I can provide a working example on my website if anyone would like to see exactly what I mean.

Upvotes: 0

Views: 1652

Answers (2)

willthiswork89
willthiswork89

Reputation: 617

The solution was to be sure that the div that is to be hovered is placed at the bottom of the page(so it does not normally mess with formatting) then to set the divs position from relative to absolute. This allows the javascript to set it and with the proper xindex, show on top.

Upvotes: 0

DACrosby
DACrosby

Reputation: 11460

Try this:

#uniquename3{
  display:none;
  position:relative;
  left:0px;
  top:10px;
  border-style: none;
  background-color: gray;
  padding: 5px;
  overflow:none;
  width:212px;
  z-index:5;
}
#uniquename3 iframe{
  display:none;
  position:absolute;
  left:0px; /* pos as needed */
  top:0px;
}

Upvotes: 1

Related Questions