function show_main(content) {
var showWindow = '<div id="show_main" style="border:1px solid #000000;color: beige;
height:40px;width:160px;position:fixed;top:50%;left:50%;
margin-left:-80px;margin-top:-20px;z-index:999;border-radius: 7px;
text-align:center;line-height:40px;filter:alpha(opacity=30);
-moz-opacity:0.3; opacity:0.3;background-color:#000000;">'
+ content + '</div>';
if ($("#show_main").length != 0) {
$('#show_main').remove();
}
$("body").append(showWindow);
$("#show_main").fadeOut(2000, removeShow_main);
}
function removeShow_main() {
var t = setTimeout($('#show_main').remove(), 2500);
}
註解:
1、居中樣式:
top:50%;
left:50%;
margin-left:-80px;/*寬度的一半*/
margin-top:-20px;/*高度的一半*/
2、透明樣式:
filter:alpha(opacity=30);
-moz-opacity:0.3;
opacity:0.3;/*三個均爲透明,針對不同的瀏覽器做兼容,0~1,1爲不透明,0完全透明*/
另:
fixed跟absolute很相似,區別爲:fixed不會隨屏幕滾動,absolute會隨屏幕滾動
摘抄來自