JQuery懸浮層 及 CSS3實現懸浮層關閉按鈕,jquerycss3

來源:互聯網
上載者:User

JQuery懸浮層 及 CSS3實現懸浮層關閉按鈕,jquerycss3

我想這樣的一個需求很是會經常遇到的,研究了一下,現在記錄下來,也希望分享給大家!

先看一下,如下所示:

代碼如下:

<span style="font-family:Times New Roman;font-size:18px;"><span style="font-family:Times New Roman;font-size:18px;"><DOCTYPE html><html><head><script type="text/javascript" src="jquery-1.7.2.min.js"></script><script type="text/javascript">$(function(){var docHeight = $(window).height();var docWidth = $(window).width();$("#overlay").height(docHeight).css({'opacity':0.8,'position':'absolute','top':0,'left':0,'background-color':'#CCCCCC','width':'100%','z-index':5000});$("<div id='popDiv'><span class='close'></span></div>").appendTo("body");var adWidth = docWidth * 0.9;var topVal = (docHeight - adWidth) * 0.5;$("#popDiv").css({'top':topVal,'left':"2%",'height':adWidth});});</script><style type="text/css">#content{width:100%;height:100px;line-height:100px;color:green;border:1px solid #ACE;text-align:center;font-size:30px;}/* the div container for pop layer */#popDiv{width:95%;height:100px;border:1px solid green;position:absolute;margin:0 auto;text-align:center;left:1%;z-index:6000;background-image:url(100.png);background-size:100% 100%;}.close{/* still bad on picking color */background: orange;color: red;/* make a round button */border-radius: 12px;/* center text */line-height: 20px;text-align: center;height: 20px;width: 20px;font-size: 18px;padding: 1px;}/* use cross as close button */.close::before {content: "\2716";//  \00D7}/* place the button on top-right */.close {top: -10px;right: -10px;position: absolute;}</style></head><body><div id="overlay"></div><div><div id="content">jQuery overlay</div></div></body></html></span></span>

註:對於按鈕中的叉按鈕,用的是Unicode中的一種標識,以下這些也可以使用:

標識 編碼(16進位) Name  
\2716 粗體乘法  
✗ \2717 交叉  
✘ \2718 粗體交叉  
× \00D7 乘法符號  
⨯ \2A2F 向量乘積  
x \78 小寫字母  
X \58 大寫字母  



jquery特效:滑鼠經過對象顯示懸浮層,超出螢幕下方後,怎判斷讓懸浮層顯示在對象上方?

怎麼又來提個問題?你提了同樣的問題兩個吧?
這個也給你回答吧!

這個很好解決嘛!

第一步將user_con的樣式設定為position:absolute

第二步先別急著給user_con show出來!先判斷下當前這個盒子的高度show出來的時候會不會超出瀏覽器螢幕!代碼改下!
$(".user").hover(function () {
var box = $(this).next();
box.show();
var _h = box.height(),
_top = box.offset().top,
_wh = $(window).height();
if (_h + _top > _wh) {
box.css({ top: (_top - _h - 20) + 'px' });
}
}, function () {
$(this).next().hide();
});
 
有關div懸浮層的問題:FirefoxGoogle裡彈出層浮在圖片上面,可是在IE6裡面卻被圖片蓋住了

要用到這個參數 z-index 一定要給他定位,不然光設一個 z-index 的值是沒有效果的。
比如給他設一個相對或者絕對就可以了
position:relative; 相對
position:absolute;絕對
position:relative; z-index:99999; 這樣就有效果了
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.