基于jquery實(shí)現(xiàn)漂亮的動(dòng)態(tài)信息提示效果
簡(jiǎn)單,漂亮,動(dòng)畫(huà)效果,用戶體驗(yàn)好!
這個(gè)效果是在頁(yè)面頭部出現(xiàn)的,出現(xiàn)一下會(huì)自動(dòng)隱藏,上面有x那個(gè)提示就要手動(dòng)關(guān)閉一下,其他的都是自動(dòng)隱藏的!
溫馨提示:基于jquery 1.6.2 版本!
<div id="message-dock">
<div id="message-sleeve" class="group">
<p><span class="sprite message-icon"></span><span id="message-text"></span><a class="dismiss"></a></p>
</div>
</div>
調(diào)用方式:
<script type="text/javascript" src="sysmsg.js"></script>
<script type="text/javascript">
ZENG.SysMsg.show('郵件格式錯(cuò)誤!', "error");
ZENG.SysMsg.show('請(qǐng)重新來(lái)過(guò)!', "alert");
ZENG.SysMsg.show('保存成功!');</script>
jquery版:
/*!
* jQuery JavaScript SysMsg v1.0
* http://zengxiangzhan.cnblogs.com/
* jQuery.sysmsg.js
* Copyright 2011, 曾祥展
* Date: 2011-8-1 20:00 2011 -2210
*/
if (!window.ZENG) var ZENG = {};
ZENG.add = function(d, f) {
var j;
if ($.isFunction(f.init)) {
j = f.init;
delete f.init;
$.extend(true, j.prototype, f);
this[d] = j
} else this[d] = f
};
ZENG.add("SysMsg", function() {
function d(u, D, v) {
D || (D = "success");
v = v || D == "error";
if (o) {
h.push(function() {
d(u, D)
});
f()
} else {
m.html(u);
i.removeClass().addClass(D).show().animate({
top: 0
}, 200, function() {
v || j()
});
o = 1
}
}
function f() {
i.animate({
top: "-50px"
}, 200, function() {
i.hide();
o = 0;
h.length && h.shift()()
})
}
function j() {
setTimeout(function() {
f()
}, 2E3)
}
var o, h = [],
i = $("#message-dock"),
m = i.find("#message-text");
$(".dismiss", "#message-dock").live("click", function(u) {
f();
u.preventDefault()
});
return {
show: d
}
}());
美觀樣式
.group {
display: block;
}
.group:after {
clear: both;
content: ".";
display: block;
height: 0;
visibility: hidden;
}
.group {
min-height: 1%;
}
* html .group {
height: 1%;
}
html, body, div,p{
background: none repeat scroll 0 0 transparent;
border: 0 none;
font-size: 100%;
margin: 0;
outline: 0 none;
vertical-align: baseline;
}
body {
color: #444444;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 75%;
line-height: 1;
}
#message-dock {
background-color: #164673;
color: #FFFFFF;
line-height: 1.75em;
padding: 10px;
position: fixed;
top: -60px;
width: 100%;
z-index: 9999;
}
#message-dock a {
color: #FFFFFF;
font-weight: bold;
text-decoration: underline;
}
#message-dock p {
border-radius: 5px 5px 5px 5px;
float: left;
padding: 5px 6px;
}
#message-dock .dismiss {
background: url("msg.png") repeat scroll -67px -180px #A12A2A;
border-radius: 0 5px 5px 0;
display: none;
float: left;
height: 21px;
padding-left: 10px;
text-indent: -999999px;
width: 20px;
cursor: pointer;
}
.sprite {
background: url("msg.png") no-repeat scroll 0 0 transparent;
display: inline-block;
vertical-align: top;
}
#message-sleeve {
margin: 0 auto;
max-width: 1200px;
min-width: 1000px;
}
.fixed #message-sleeve {
width: 1000px;
}
#message-text {
float: left;
font-size: 1.16667em;
padding: 0 10px 0 0;
}
.success p {
background-color: #7AA13D;
}
.alert p {
background-color: #FFF095;
color: #333333;
}
.alert a {
color: #333333 !important;
}
.error p {
background-color: #A12A2A;
padding-right: 0 !important;
}
.error #message-text {
padding-right: 0;
}
.error .dismiss {
display: block !important;
}
.error .message-icon, .alert .message-icon {
background-position: 0 -249px;
}
.message-icon {
background-position: -21px -249px;
float: left;
height: 21px;
margin-right: 6px;
position: relative;
width: 21px;
}
附件:

完畢!
- jquery提示效果實(shí)例分析
- jQuery提示效果代碼分享
- Jquery中國(guó)地圖熱點(diǎn)效果-鼠標(biāo)經(jīng)過(guò)彈出提示層信息的簡(jiǎn)單實(shí)例
- jquery實(shí)現(xiàn)非疊加式的搜索框提示效果
- jquery實(shí)現(xiàn)網(wǎng)站超鏈接和圖片提示效果
- jquery中dom操作和事件的實(shí)例學(xué)習(xí) 仿yahoo郵箱登錄框的提示效果
- 基于jquery的loading 加載提示效果實(shí)現(xiàn)代碼
- 基于JQuery 的消息提示框效果代碼
- Jquery實(shí)現(xiàn)地鐵線路指示燈提示牌效果的方法
相關(guān)文章
商城常用滾動(dòng)的焦點(diǎn)圖效果代碼簡(jiǎn)單實(shí)用
此效果在網(wǎng)上使用的頻率比較多一點(diǎn)但大多是插件,要么JS寫的太過(guò)于復(fù)雜童鞋們看起來(lái)有一定的難度,這個(gè)相對(duì)來(lái)說(shuō)比較簡(jiǎn)單一點(diǎn),感興趣的可以參考下哈2013-03-03利用jQuery簡(jiǎn)單實(shí)現(xiàn)產(chǎn)品展示圖片左右滾動(dòng)功能(示例代碼)
本篇文章主要是對(duì)利用jQuery簡(jiǎn)單實(shí)現(xiàn)產(chǎn)品展示圖片左右滾動(dòng)功能的示例代碼進(jìn)行了介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-01-01傳遞參數(shù)的標(biāo)準(zhǔn)方法(jQuery.ajax)
jQuery.ajax傳遞參數(shù)的方法2008-11-11jQuery取得元素標(biāo)簽名稱小結(jié)(附代碼)
這篇文章主要介紹了 jquery如何取得元素標(biāo)簽名稱,將html和js代碼附上,具體操作步驟大家可查看下文的詳細(xì)講解,感興趣的小伙伴們可以參考一下。2017-08-08jquery獲取div寬度的實(shí)現(xiàn)思路與代碼
DIV的width寬度如何獲取呢?接下來(lái)介紹使用jquery獲取DIV的width寬度,感興趣的朋友可以了解下的2013-01-01jquery radio的取值_radio的選中_radio的重置方法
下面小編就為大家?guī)?lái)一篇jquery radio的取值_radio的選中_radio的重置方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-09-09利用jQuery操作對(duì)象數(shù)組的實(shí)現(xiàn)代碼
利用jQuery操作對(duì)象數(shù)組的實(shí)現(xiàn)代碼,需要的朋友可以參考下。2011-04-04jquery 取子節(jié)點(diǎn)及當(dāng)前節(jié)點(diǎn)屬性值
本節(jié)主要介紹了jquery如何取子節(jié)點(diǎn)及當(dāng)前節(jié)點(diǎn)屬性值,需要的朋友可以參考下2014-07-0710分鐘學(xué)會(huì)寫Jquery插件實(shí)例教程
這篇文章主要介紹了10分鐘學(xué)會(huì)寫Jquery插件,通過(guò)一個(gè)實(shí)例分兩步完成一個(gè)簡(jiǎn)單的插件,非常實(shí)用,需要的朋友可以參考下2014-09-09