8 replies [Last post]
chevywes
chevywes's picture
User offline. Last seen 3 years 19 weeks ago. Offline
rank Regular
Regular
Timezone: GMT-11
Joined: 2008-07-17
Posts: 32
Points: 0

Hi all
I was trying to figure out how to make a pop-up box appear when you hover over "contact" or either click on it, either way would work for me. I have no clue what to do or were to start.

Thanks for all your help
chevywes

ps hopefully my book " Build your own web site the right way using HTML and CSS - by Ian Lloyd
will be here next week.

flashcat7777
flashcat7777's picture
User offline. Last seen 1 year 39 weeks ago. Offline
rank Enthusiast
Enthusiast
Timezone: GMT-5
Joined: 2006-05-29
Posts: 64
Points: 5

I will assume that the pop

I will assume that the pop up box you want is a

, so give it a unique ID and a display of none (to hide it) (
). Then create a javascript function similar to the following:
function change()
{
  if(document.getElementById("mydiv").style.display="none")
    document.getElementById("mydiv").style.display="block";
  else
    document.getElementById("mydiv").style.display="none";
}

Then, when you create the link, you can call the javascript:
This is the link

This is more of a Javascript question, but I'm happy to help all the same Smile

chevywes
chevywes's picture
User offline. Last seen 3 years 19 weeks ago. Offline
rank Regular
Regular
Timezone: GMT-11
Joined: 2008-07-17
Posts: 32
Points: 0

pop up box

Thanks for steering me in the right direction.
I appreciate all the help.
chevywes

chevywes
chevywes's picture
User offline. Last seen 3 years 19 weeks ago. Offline
rank Regular
Regular
Timezone: GMT-11
Joined: 2008-07-17
Posts: 32
Points: 0

pop up box

how do I make the box and were do I put it (that's a loaded question isn't). do I put it in the same div as the code above or in a seperate div or not in a div at all.

I take it that I call the box up with the above code .... right

I apologize for my stupidity (maybe I should read comic books for a hobby) and thank you all for your patience and help.

flashcat7777
flashcat7777's picture
User offline. Last seen 1 year 39 weeks ago. Offline
rank Enthusiast
Enthusiast
Timezone: GMT-5
Joined: 2006-05-29
Posts: 64
Points: 5

If you're asking how to

If you're asking how to create the box, that depends. If you want to have the box follow the mouse, that will be more difficult and use more Javascript. However, if you want a box to "appear" in a certain position, and be the topmost element, you can use some simple CSS.

In the head of your document, you can define style for the ID for the box, like this:

<style type="text/css">
#mydiv {
position: absolute;
display: none;
top: 20px;
left: 20px;
width: 80px;
height: 80px;
z-index: 100;
}
</style>

That will create a 80 x 80 pixel box 20px from the top of the screen and 20px from the left of the screen. Instead of using top and left, you can use margin-left: and margin-top: to space the box from its container rather than the absolute screen. Since I added the display: none; you can remove the style attribute from the HTML.

Hope this helps!

chevywes
chevywes's picture
User offline. Last seen 3 years 19 weeks ago. Offline
rank Regular
Regular
Timezone: GMT-11
Joined: 2008-07-17
Posts: 32
Points: 0

pop up box

Thanks for all your help.

I changed things around a bit, with the help of a friend.

I'll try and send an attachment.

Thanks again
wes

AttachmentSize
hover.txt 841 bytes
flashcat7777
flashcat7777's picture
User offline. Last seen 1 year 39 weeks ago. Offline
rank Enthusiast
Enthusiast
Timezone: GMT-5
Joined: 2006-05-29
Posts: 64
Points: 5

After a quick glance, that

After a quick glance, that seems to work just fine. There's always more than one way to skin a cat Smile

techSuda
techSuda's picture
User offline. Last seen 2 years 47 weeks ago. Offline
newbie
Timezone: GMT+5.5
Joined: 2008-09-09
Posts: 2
Points: 0

Can this effect achieved using ONLY CSS

Hi guys. Solution to above problem is JavaScript. But can it be done in CSS ONLY?? :?

I tried like this.

In HTML

<dive id= "header">
Title of Site
<div id="headerwindow">This is in popup window</div>
</div>

And in CSS
#header{
font:...
color:
......
}
#headerwindow{
dispaly:none;
}
 
/*for required effect
#header.hover{
???????
}

What I should put at ????? to set "display" of #headerwindow to "block" ? Or is it possible actually?

techSuda
techSuda's picture
User offline. Last seen 2 years 47 weeks ago. Offline
newbie
Timezone: GMT+5.5
Joined: 2008-09-09
Posts: 2
Points: 0

I found solution

I found solution after many trials.
What I did is
In HTML

<dive id= "header">
Title of Site<span>This is in popup window</span></div>
</div>

and In CSS

#header{
blah blah
}
#header span{
display: none;
}
#header:hover span{
display: block;
}

And it worked. This is primary solution, will need some refinement. But at least it worked. Thanks.