|
![]() |
Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Web Coding | |
How To: Make CSS Tooltips/Picture Rollovers
|
||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) | ||||||||||||
|
Programmer
|
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;}
Code:
<a class="tooltip" id="tt1" href="#" > Roll over this <span>For this tooltip!</span> </a> 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>
__________________
"If there is a god, I hope he has a good excuse" Woody Allen
Last edited by stupid : 03-22-07 at 03:30 PM. Reason: editing problems |
||||||||||||
|
|
|
|
|
#2 (permalink) | |||||||||||||
|
Programmer
|
This is decent, nice one
__________________
Info: Static Electricity How To: Tweak windows to show file extensions How To: Get around Internet Explorer's rendering bugs (for web coders) ![]() "You're never late 'till you show up"
|
|||||||||||||
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|