Hover Image Text

码农软件 · 软件分类 · 其他jQuery插件 · 2020-01-09 11:57:29

软件介绍

* Added live demo page (url at bottom of page) - Updated! to bring scrollup animation and fixed width list!

This project allows you to create images along with descriptive text that is displayed on mouse over, similar to a tool hip, however the text is overlayed over the image.

I had seen similar examples of this functionality on the internet, some using flash and others javascript.

This is my first project using jQuery and I thought it might be useful for others.

You simple create some images (can be listed together or separately) along with there text descriptions:

<ul class="imageLibrary">
<li><a target="_blank" rel="nofollow" href="http://www.bbc.co.uk/go/homepage/int/wil/wth/5day/t/-/weather/5day.shtml"><p>Wednesday<br />max: 9°C<br />min :5°C</p><img src="http://www.bbc.co.uk/home/img/weather/1.gif" /></a></li>
<li><a target="_blank" rel="nofollow" href="http://www.bbc.co.uk/go/homepage/int/wil/wth/5day/t/-/weather/5day.shtml"><p>Thursday<br />max: 10°C<br />min :7°C</p><img src="http://www.bbc.co.uk/home/img/weather/14.gif" /></a></li>
<li><a target="_blank" rel="nofollow" href="http://www.bbc.co.uk/go/homepage/int/wil/wth/5day/t/-/weather/5day.shtml"><p>Friday<br />max: 13°C<br />min :10°C</p><img src="http://www.bbc.co.uk/home/img/weather/12.gif" /></a></li>
</ul>

That's the hard part done... ;-)

Now you need to include the jQuery javascript and the HoverImageText plugin javascript, add the following to your HEAD section:

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="jquery.hoverimagetext.js"></script>

To activate the HoverImageText plugin you'll need to give it some data (the a elements that you created earlier will be fine), add this underneath the script includes above:

<script type="text/javascript">
$(document).ready(function() {
/* options can be found within the plugin js */
$('.imageLibrary a').HoverImageText();
});
</script>

Notice the '.imageLibrary a' selection, that will select the anchor (a) elements from my example above.

That's it... you've done it, it should now display the image text when you move your mouse over the images.

Of course, it doesn't look that pretty at the moment... add some style and you'll be away!

<style type="text/css">
/* your own style sheet, here are some examples */
.imageLibrary {
display: inline;
clear: none;
}
.imageLibrary li {
list-style-type: none;
margin-left: 10px;
display: inline;
clear: none;
}
.imageLibrary p {
position: absolute;
margin: 0px;
margin-left: 2px;
margin-top: 2px;
z-index:2;
background-Color: #555555;
color: #ffffff;
width: 80px;
text-align: center;
padding-top: 5px;
padding-bottom: 5px;
opacity:.8;
display: none;
clear: none;
}
.imageLibrary img {
z-index:1;
width: 80px;
height: 80px;
border: #888888 groove 2px;
}
</style>

The full example page is included in the download release.

As mentioned earlier, your image (and text) elements need not be listed together (like in the example above), you can of course create numerous images scattered around your web page... You will of course need to contain them and style them, I used the anchor (a) element in the example, you could use something else if you like (div, span...).

Well that's it for now, enjoy!

My other projects include:
Bounce - http://plugins.jquery.com/project/Bounce
TextArea Resizer - http://plugins.jquery.com/project/TextAreaResizer

本文地址:https://codercto.com/soft/d/22996.html

未来简史

未来简史

[以色列] 尤瓦尔·赫拉利 / 林俊宏 / 中信出版集团 / 2017-2 / 68.00元

进入21世纪后,曾经长期威胁人类生存、发展的瘟疫、饥荒和战争已经被攻克,智人面临着新的待办议题:永生不老、幸福快乐和成为具有“神性”的人类。在解决这些新问题的过程中,科学技术的发展将颠覆我们很多当下认为无需佐证的“常识”,比如人文主义所推崇的自由意志将面临严峻挑战,机器将会代替人类做出更明智的选择。 更重要的,当以大数据、人工智能为代表的科学技术发展的日益成熟,人类将面临着从进化到智人以来z......一起来看看 《未来简史》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具