国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

qTip 基于JQuery的Tooltip插件[兼容性好]

2019-11-21 00:16:12
字體:
來源:轉載
供稿:網友

主頁:http://craigsworks.com/projects/qtip/

下載:http://craigsworks.com/projects/qtip/download

示例:http://craigsworks.com/projects/qtip/

qTip是一個基于JQuery的Tooltip插件。它幾乎支持所有的主流瀏覽器
例如:

Internet Explorer 6.0+
Firefox 2.0+
Opera 9.0+
Safari 3.0+
Google Chrome 1.0+
Konqueror 3.5+

使用qTip可以很輕松的定義tip的位置以及樣式,同時qTip還有一個強大的API......

使用qTip前,只需引入兩個JS文件即可:

復制代碼 代碼如下:

<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="jquery.qtip-1.0.0-rc3.min.js"></script>

下面舉幾個比較簡單的例子。

1、Basic text

html如下所示:
復制代碼 代碼如下:

<div id="content">
<a href=" ">Basic text</a>
</div>

JS代碼:
復制代碼 代碼如下:

<script type="text/javascript">
$(document).ready(function()
{
$('#content a[href]').qtip(
{
content: 'Some basic content for the tooltip'
});
});
</script>

2、Title attribute

html如下所示:
復制代碼 代碼如下:

<div id="content">
<a href=" " title="That sounds familiar...">Title attribute</a>
</div>

JS代碼:
復制代碼 代碼如下:

<script type="text/javascript">
$(document).ready(function()
{
$('#content a[href][title]').qtip({
content: {
text: false
},
style: 'cream'
});
});
</script>

3、Image

html如下所示:
復制代碼 代碼如下:

<div id="content">
<a href=" ">Image</a>
</div>

JS代碼:
復制代碼 代碼如下:

<script type="text/javascript">
$(document).ready(function()
{
$('#content a[href]').qtip({
content: '<img src="small.png" alt="Image" />'
});
});
</script>

4、Corner values

html如下所示:
復制代碼 代碼如下:

<div id="content" style="margin-top:200px;margin-left:200px;">
<a href=" ">Corner values</a>
</div>

JS代碼:
復制代碼 代碼如下:

<script type="text/javascript">
var corners = 'bottomLeft';
var opposites = 'topRight';
$(document).ready(function()
{
$('#content a')
.hover(function()
{
$(this).html(opposites)
.qtip({
content: corners,
position: {
corner: {
tooltip: corners,
target: opposites
}
},
show: {
when: false,
ready: true
},
hide: false,
style: {
border: {
width: 5,
radius: 10
},
padding: 10,
textAlign: 'center',
tip: true,
name: 'cream'
}
});
});
});
</script>

5、Fixed tooltips

html如下所示:
復制代碼 代碼如下:

<div id="content">
<img src="sample.jpg" alt="" height="200" />
</div>

JS代碼:

復制代碼 代碼如下:

<script type="text/javascript">
$(document).ready(function()
{
$('#content img').each(function()
{
$(this).qtip(
{
content: '<a href=" ">Edit</a> | <a href=" ">Delete</a>',
position: 'topRight',
hide: {
fixed: true
},
style: {
padding: '5px 15px',
name: 'cream'
}
});
});
});
</script>

css代碼:

復制代碼 代碼如下:

<style type="text/css">
#content img{
float: left;
margin-right: 35px;
border: 2px solid #454545;
padding: 1px;
}
</style>

6、Loading html

html如下所示:

Html代碼
復制代碼 代碼如下:

<div id="content">
<a href="#" rel="sample.html">Click me</a>
</div>

JS代碼:

復制代碼 代碼如下:

<script type="text/javascript">
$(document).ready(function()
{
$('#content a[rel]').each(function()
{
$(this).qtip(
{
content: {
url: $(this).attr('rel'),
title: {
text: 'Wiki - ' + $(this).text(),
button: 'Close'
}
},
position: {
corner: {
target: 'bottomMiddle',
tooltip: 'topMiddle'
},
adjust: {
screen: true
}
},
show: {
when: 'click',
solo: true
},
hide: 'unfocus',
style: {
tip: true,
border: {
width: 0,
radius: 4
},
name: 'light',
width: 570
}
})
});
});
</script>

7、Modal tooltips

html如下所示:

Html代碼
復制代碼 代碼如下:

<div id="content">
<a href="#" rel="modal">Click here</a>
</div>


JS代碼:
復制代碼 代碼如下:

<script type="text/javascript">
$(document).ready(function()
{
$('a[rel="modal"]:first').qtip(
{
content: {
title: {
text: 'Modal tooltips sample',
button: 'Close'
},
text: 'hello world'
},
position: {
target: $(document.body),
corner: 'center'
},
show: {
when: 'click',
solo: true
},
hide: false,
style: {
width: { max: 350 },
padding: '14px',
border: {
width: 9,
radius: 9,
color: '#666666'
},
name: 'light'
},
api: {
beforeShow: function()
{
$('#qtip-blanket').fadeIn(this.options.show.effect.length);
},
beforeHide: function()
{
$('#qtip-blanket').fadeOut(this.options.hide.effect.length);
}
}
});
$('<div id="qtip-blanket">')
.css({
position: 'absolute',
top: $(document).scrollTop(),
left: 0,
height: $(document).height(),
width: '100%',
opacity: 0.7,
backgroundColor: 'black',
zIndex: 5000
})
.appendTo(document.body)
.hide();
});
</script>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 海兴县| 玉树县| 皮山县| 镇原县| 长寿区| 乌什县| 普定县| 方山县| 兰坪| 达尔| 务川| 福泉市| 南丹县| 兴宁市| 辽宁省| 佛教| 香河县| 兴国县| 于田县| 南阳市| 两当县| 鄄城县| 兴业县| 靖州| 招远市| 建水县| 德阳市| 鹤峰县| 尼玛县| 河源市| 米泉市| 阿坝| 鹤山市| 定远县| 图木舒克市| 丹巴县| 伊宁市| 曲靖市| 万源市| 文山县| 孝昌县|