Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Web Coding

Reply
 
LinkBack Thread Tools
Old 03-22-07   #1 (permalink)
Programmer
 
stupid's Avatar
 
amd nvidia

Join Date: Jan 2006
Location: Fahaheel, Kuwait
Posts: 1,239

Rep: 147 stupid is acknowledged by manystupid is acknowledged by many
Unique Rep: 116
FAQs Submitted: 1
Trader Rating: 4
Default How To: Make CSS Tooltips/Picture Rollovers

In the past, I have made tooltips with JavaScript, and that can get lengthy and messy - I prefer to use JavaScript as little as possible. So I recently figured out a new way (probably notall that new, but new to me) to make tooltips and picture enlarging rollovers that is very simple and uses nothing but css and html.

First thing is to add classes either into your <style> section in the <head> of your document, or your seperate style sheet:

Code:
a.tooltip{position:relative; z-index:24;}
a.tooltip:hover{z-index:25;}
a.tooltipspan{display: none; }
a.tooltip:hoverspan{ /*display just on :hover state*/
display:block; text-decoration:none;
/* for text, you might want to add a width 
to make the tooltip write within a box */
/*this positions it relative to the link (edit if you want)*/
position:absolute; top:1em; left:1em;
/*edit anything below here to preference*/
padding:2px; border:1px solid Black; background-color:Gray;}
Now that that is all set, we just use our created elements to make our tooltip:

Code:
<a class="tooltip" id="tt1" href="#" >
 Roll over this
 <span>For this tooltip!</span>
</a>
Also, I used this to display pictures as as thumbnails, but on a rollover, shows them at 100% size (great for eBay):

Code:
<a class="tooltip" id="tt2" href="#">
 <img src="images/random.jpg" alt="small image" style="width:50px;" />
 <span><img src="images/random.jpg" alt="full image" /></span>
</a>
This way, everything that is within the <a> and the <span> is inside the tooltip, and everything that is within the <a> and outside the <span> is the thing that you rollover to view the tooltip.
__________________
"If there is a god, I hope he has a good excuse"
Woody Allen

System: Minazo
CPU
Opteron 1210
Motherboard
Biostar TForce 550 SE
Memory
2x1GB G.Skill DDR2 800
Graphics Card
eVGA 8800GT
Hard Drive
500GB 16MB Buf Samsung
Power Supply
Corsair HX520W Modular
Case
CoolerMaster Centurion 5
CPU cooling
CoolerMaster GeminII & Scythe SFF21Ds
GPU cooling
Accelero S1 & Scythe SFF21D
OS
XP Pro SP2
Monitor
Dual monitors: 22" & 19" Widescreens

Last edited by stupid : 03-22-07 at 03:30 PM. Reason: editing problems
stupid is offline   Reply With Quote
Old 03-27-07   #2 (permalink)
Programmer
 
sniperscope's Avatar
 
amd nvidia

Join Date: Apr 2006
Location: Kent (England)
Posts: 1,237

Rep: 89 sniperscope is acknowledged by some
Unique Rep: 77
FAQs Submitted: 3
Folding Team Rank: 2540
Trader Rating: 0
Default

This is decent, nice one

System: Bob
CPU
AMD Athlon 64 3800+
Motherboard
ASUS A8N- SLI Premium
Memory
2GB (2X1GB) Corsair XMS Pro LED TwinX DDR400
Graphics Card
XFX GeForce 7800GT Extreme Edition
Hard Drive
2x200GB Barracuda SATA RAID0 + 250Gb ATA
Sound Card
AC'97
Power Supply
Antec TruePower 550W
Case
Thermaltake Armour
CPU cooling
Stock
GPU cooling
Stock
OS
Windows Vista Home Premium x64
Monitor
Hanns G 19" widescreen HW191D
sniperscope is offline I fold for Overclock.net sniperscope's Gallery   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 12:44 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.29266 seconds with 8 queries