When you move the mouse over an image, the system displays the enlarged image following the mouse.

Source: Internet
Author: User

Original Status:

Mouse:
Copy codeThe Code is as follows: <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
<Script language = "javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"> </script>
<Script language = "javascript">
$ (Function (){
Var offsetX = 20-$ ("# imgtest"). offset (). left;
Var offsetY = 20-$ ("# imgtest"). offset (). top;
Var size = 1.2 * $ ('# imgtest ul li img'). width ();
$ ("# Imgtest ul li"). mouseover (function (event ){
Var implements targetmediaworkflow (event.tar get );
If ($ target. is ('img '))
{
$ ("<Img id = 'tip 'src = '" + $ target. attr ("src") + "'>" example .css ({
"Height": size,
"Width": size,
"Top": event. pageX + offsetX,
"Left": event. pageY + offsetY,
}). AppendTo ($ ("# imgtest "));
}
}). Mouseout (function (){
$ ("# Tip"). remove ();
}). Mousemove (function (event ){
$ ("# Tip" ).css (
{
"Left": event. pageX + offsetX,
"Top": event. pageY + offsetY
});
});
})
</Script>
<Style type = "text/css">
Img {height: 262px; width: 400px; position: absolute; border: 5px solid # FFF ;}
# Imgtest {height: auto; width: 840px; margin: 0 auto; position: absolute ;}
# Imgtest ul {position: relative; width: 840px; height: auto; background: # 00F ;}
# Imgtest ul li {position: relative; height: 276px; width: pixel PX; list-style: none; float: left; margin: 3px; border: 1px solid #999 ;}
</Style>
</Head>
<Body>
<Div id = "imgtest">
<Ul>
<Li> </li>
<Li> </li>
<Li> </li>
<Li> </li>
</Ul>
</Div>
</Body>
</Html>

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.