Jump to content

Overlapping Content?


rockinaway

Recommended Posts

You need to combine CSS and JavaScript (this is call DHTML). You will need to create a div and set the style to what ever you want; but be sure to set the display to "none" and the position to "absolute". Then set the z-index to something like; I don't know, I always use "1000" of more. You may also have to play around with the margins of the overlapping div. Then set you JavaScript like this:

 

<script language="javascript">
function showDIV(myDIV)
{
document.getElementById(myDIV).style.display='block';
}
function hideDIV(myDIV)
{
document.getElementById(myDIV).style.display='none';
}
</script>

<div id="overlap1">
<a href="javascript:hideDIV('overlap1')">Close Me</a>
</div>

<br><br>

<a href="javascript:showDIV('overlap1')">Open Overlap Content</a>

Link to comment
Share on other sites

If you want it to overlap; you will have to set the CSS style position to "absolute" and set the z-index higher then the rest of your elements/tags.

 

This Will Overlap:

 

<script language="javascript">
function showDIV(myDIV)
{
document.getElementById(myDIV).style.display='block';
}
function hideDIV(myDIV)
{
document.getElementById(myDIV).style.display='none';
}
</script>

<div id="overlap1" style="position:absolute;z-index:1000;width:300px;height:300px;display:none;background:white;border:solid 1px black">
<a href="javascript:hideDIV('overlap1')">Close Me</a>
</div>

Content Here...........................................................................

<br><br>

<a href="javascript:showDIV('overlap1')">Open Overlap Content</a>

 

You may have to play with the margins a bit.

 

The original code will just show/hide content; I just assumed you knew how to use CSS to style the DIV tag - sorry about that.

Link to comment
Share on other sites

  • 2 weeks later...

I mean the positioning of the div is underneath the button.. so like

 

[button1][button2][button3] 
                  [DIV appear here when button 3 clicked]

 

At the moment, eventhough button3 is clicked, the DIV appears below button1, at the start of the page.. how can I move it so that it appears below 3?

Link to comment
Share on other sites

<input type="button" value="Button 1">
<input type="button" value="Button 2">
<input type="button" value="Button 3">
<script language="javascript">
function showDIV(myDIV)
{
document.getElementById(myDIV).style.display='block';
}
function hideDIV(myDIV)
{
document.getElementById(myDIV).style.display='none';
}
</script>

<div id="overlap1" style="position:absolute;z-index:1000;width:300px;height:300px;display:none;background:white;border:solid 1px black">
<a href="javascript:hideDIV('overlap1')">Close Me</a>
</div>

<br><br>

<a href="javascript:showDIV('overlap1')">Open Overlap Content</a>

Link to comment
Share on other sites

<input type="button" value="Button 1">
<input type="button" value="Button 2">
<input type="button" value="Button 3">
<script language="javascript">
function showDIV(myDIV)
{
document.getElementById(myDIV).style.display='block';
}
function hideDIV(myDIV)
{
document.getElementById(myDIV).style.display='none';
}
</script>

<div id="overlap1" style="position:absolute;z-index:1000;width:300px;height:300px;display:none;background:white;border:solid 1px black;overflow:hidden">
<a href="javascript:hideDIV('overlap1')">Close Me</a>
<table width=100% height=90% border=1 align=left valign=top>
<td width=100% height=90% border=1 align=left valign=top>
Table Content
</td>
</table>
</div>

<br><br>

<a href="javascript:showDIV('overlap1')">Open Over</a>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.