Pure CSS Tooltips

Source: Internet
Author: User

In fact, there are many Tooltips methods, but most of them are implemented using Javascript.
For example, ikshow.cn, using JavaScript, DHTML Tooltips.
I admit that my Javascript is very watery ...... However, CSS can be simpler and more efficient. The most important thing is to comply with the standards.
We add the position: relative attribute to the class so that the position of the span tag can be followed by the link.
Let's take a look at the specific code:
Run code box
<Br/>
<A class = "tooltips" href = "# tooltips"> This is Tooltips <span> as you can see, these additional instructions are displayed when the mouse passes. </Span> </a>
<Style type = "text/css">
/* Tooltips */
. Tooltips {
Position: relative;/* This is the key */
Z-index: 2;
}
. Tooltips: hover {
Z-index: 3;
Background: none;/* not available in IE */
}
. Tooltips span {
Display: none;
}
. Tooltips: hover span {/* The span label is only displayed in the hover status */
Display: block;
Position: absolute;
Top: 21px;
Left: 9px;
Width: 15em;
Border: 1px solid black;
Background-color: # ccFFFF;
Padding: 3px;
Color: black;
}
</Style>
[Ctrl + A Select All tips: You can modify some code and then press run]
Define z-index to ensure that the pop-up Tooltips layer is at the top.
Use: After defining the preceding class, apply the class to a specific label. The span label in the label will be used as Tooltips. For example:
<A class = "tooltips" href = "# tooltips"> This is Tooltips <span> as you can see, these additional instructions are displayed when the mouse passes. </Span> </a>
The above method is suitable for most existing browsers, such as Firefox and IE.
Because most existing browsers support the use of any label for the hover selector (refer to whatever: hover ). for browsers that only use the tag, all we need to do is add "a" before the class ". The details are as follows:
/* Tooltips */
A. tooltips {
Position: relative;/* This is the key */
Z-index: 2;
}
A. tooltips: hover {
Z-index: 3;
Background: none;/* not available in IE */
}
A. tooltips span {
Display: none;
}
A. tooltips: hover span {/* The span label is displayed only when the hover status is displayed */
Display: block;
Position: absolute;
Top: 9px;
Left: 9px;
Width: 15em;
Border: 1px solid black;
Background-color: # ccFFFF;
Padding: 3px;
Color: black;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.