<!DOCTYPE HTML>
<html>
<head>
<title>jQuery-Image-ToolTips</title>
<script type="text/javascript" src="js/jquery-1.4.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('div.thumbnail-item').mouseenter(function(e) {
x = e.pageX - $(this).offset().left;
y = e.pageY - $(this).offset().top;
$(this).css('z-index','15')
.children("div.tooltip")
.css({'top': y + 10,'left': x + 20,'display':'block'});
}).mousemove(function(e) {
x = e.pageX - $(this).offset().left;
y = e.pageY - $(this).offset().top;
$(this).children("div.tooltip").css({'top': y + 10,'left': x + 20});
}).mouseleave(function() {
$(this).css('z-index','1')
.children("div.tooltip")
.animate({"opacity": "hide"}, "fast");
});
});
</script>
<style>
.thumbnail-item {
position: relative;
float: left;
margin: 0px 5px;
}
.thumbnail-item a {
display: block;
}
.thumbnail-item img.thumbnail {
border:3px solid #ccc;
}
.tooltip {
display: none;
position: absolute;
padding: 8px 0 0 8px;
}
.tooltip span.overlay {
background: url(images/overlay.png) no-repeat;
position: absolute;
top: 0px;
left: 0px;
display: block;
width: 350px;
height: 200px;
}
</style>
</head>
<body>
<div class="thumbnail-item">
<a href="#"><img src="images/small1.jpg" class="thumbnail"/></a>
<div class="tooltip">
<img src="images/big1.jpg" alt="" width="330" height="185" />
<span class="overlay"></span>
</div>
</div>
<div class="thumbnail-item">
<a href="#"><img src="images/small2.jpg" class="thumbnail"/></a>
<div class="tooltip">
<img src="images/big2.jpg" alt="" width="330" height="185" />
<span class="overlay"></span>
</div>
</div>
<div class="thumbnail-item">
<a href="#"><img src="images/small3.jpg" class="thumbnail"/></a>
<div class="tooltip">
<img src="images/big3.jpg" alt="" width="330" height="185" />
<span class="overlay"></span>
</div>
</div>
<div class="clear"></div>
</body>
</html>
<html>
<head>
<title>jQuery-Image-ToolTips</title>
<script type="text/javascript" src="js/jquery-1.4.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('div.thumbnail-item').mouseenter(function(e) {
x = e.pageX - $(this).offset().left;
y = e.pageY - $(this).offset().top;
$(this).css('z-index','15')
.children("div.tooltip")
.css({'top': y + 10,'left': x + 20,'display':'block'});
}).mousemove(function(e) {
x = e.pageX - $(this).offset().left;
y = e.pageY - $(this).offset().top;
$(this).children("div.tooltip").css({'top': y + 10,'left': x + 20});
}).mouseleave(function() {
$(this).css('z-index','1')
.children("div.tooltip")
.animate({"opacity": "hide"}, "fast");
});
});
</script>
<style>
.thumbnail-item {
position: relative;
float: left;
margin: 0px 5px;
}
.thumbnail-item a {
display: block;
}
.thumbnail-item img.thumbnail {
border:3px solid #ccc;
}
.tooltip {
display: none;
position: absolute;
padding: 8px 0 0 8px;
}
.tooltip span.overlay {
background: url(images/overlay.png) no-repeat;
position: absolute;
top: 0px;
left: 0px;
display: block;
width: 350px;
height: 200px;
}
</style>
</head>
<body>
<div class="thumbnail-item">
<a href="#"><img src="images/small1.jpg" class="thumbnail"/></a>
<div class="tooltip">
<img src="images/big1.jpg" alt="" width="330" height="185" />
<span class="overlay"></span>
</div>
</div>
<div class="thumbnail-item">
<a href="#"><img src="images/small2.jpg" class="thumbnail"/></a>
<div class="tooltip">
<img src="images/big2.jpg" alt="" width="330" height="185" />
<span class="overlay"></span>
</div>
</div>
<div class="thumbnail-item">
<a href="#"><img src="images/small3.jpg" class="thumbnail"/></a>
<div class="tooltip">
<img src="images/big3.jpg" alt="" width="330" height="185" />
<span class="overlay"></span>
</div>
</div>
<div class="clear"></div>
</body>
</html>
No comments:
Post a Comment