Helping ordinary people create extraordinary websites!

Go Back   Web Development Forum > Website Designing > HTML/CSS
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-08-2008, 07:23 AM
ryanhellyer's Avatar
Super Moderator
 
Join Date: Dec 2007
Posts: 707
Default Pop ups that aren't actually pop ups!

This is in response to the following question which was posted in the client side scripting forum. It is more of an HTML/CSS question hence I'm answering it here ...

Quote:
Originally Posted by dilipv View Post
... i did saw the Pop windows in one of the website. just follow the following url.

http://www.webforumz.com/graphics-fo...and-banner.htm

In the above given link,just scroll to the fourth post, there you will find a hyper linked word " reading " powers have left us... if you place mouse on it you will
find something. i wanted to do the same on my site ....
That is not a pop up. It looks like a pop up but technically is not as it is still the same page.

What they've done there is use a CSS mouseover. It is the same technique used for creating dropdown menus and various other on page features.

What happens, is that when you roll over the piece of text, it changes the CSS value for the box which appears from display:none to display:block in the CSS.

Here is a crude demo of how this works:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Hover demo</title>
<style type="text/css">
    a div {display:none}
    a:hover div {display:block}
</style>
</head>
<body>

<a href="#">Hover over me<div>some random text</div></a>

</body>
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-08-2008, 07:26 AM
ryanhellyer's Avatar
Super Moderator
 
Join Date: Dec 2007
Posts: 707
Default

One more thing ...

You can add as much content, styling and whatever else you want to include inside the DIV tag in the demo above. All of the content of the DIV will be hidden until you hover over the link.

You can also achieve the same effect with other elements which support the :hover pseudo tag, so you don't always need to use a link tag, although that it is probably the most common way to do it.

You can position the "pop up" with relative positioning to move it's position relative to the thing you are hovering over.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-08-2008, 07:29 AM
ryanhellyer's Avatar
Super Moderator
 
Join Date: Dec 2007
Posts: 707
Default

Actually ... I've had a sudden brain surge (it's 1:30am here at the moment) ...

That particular example you showed is probably not entirely generated by this technique, it may be Javascript generated. Although the principle is still the same and the method I've outlined above is likely to be more useful to you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-12-2008, 02:12 AM
Junior Member
 
Join Date: Feb 2008
Posts: 9
Default Pop up menus

hi ryanhellyer,

i saw your quote.i i would like to thank you once again for your reply.
i tried the code and i am happy that it's working
can you please explain the code. i wanted to know what does this following code do.
<style type="text/css">
a div {display:none}
a:hover div {display:block}
can you tell me how to create dropdown menu in javascript.

Thank you
Jitesh
__________________
Programmer
.Net Consulting
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-13-2008, 04:26 AM
ryanhellyer's Avatar
Super Moderator
 
Join Date: Dec 2007
Posts: 707
Default

The code you have pointed out there is the CSS which controls how the div tag behaves when it is inside a link, both as normal and when hovered over with the mouse.

Display:none indicates that you can not see div at all and display:block indicates that it will be displayed as a block element. Hopefully that makes some sense!


In general, you should avoid creating dropdowns in Javascript and only use the Javascript to help out older browsers like IE6 which can not handle basic CSS.

I've created a WordPress plugin for creating dropdown menus which may be useful as a demonstration for you ... Plugin page | Demo page

If you have a look at the code on the demo page, you will see that the CSS file controls the behaviour of the dropdown and there is a small Javascript to kick the menu down in older versions of IE. There are quite a few things going on in the creation of such dropdowns so I suggest having a go at modifying/adapting the code for your own needs and if you have any troubles post back here.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 02:54 AM.


Website Design by Ducani Media Group
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.