自訂彈出層置中並顯示遮罩,置中遮罩

來源:互聯網
上載者:User

自訂彈出層置中並顯示遮罩,置中遮罩

1.自己先定義兩個div,一個是用來放彈出層內容的,一個是用於設定遮罩層顏色的,一個觸發顯示彈出層的按鈕

2.給兩個div分別設定css樣式,遮罩的樣式主要有:position:fixed;z-index:2;background-color:#000;opacity:0.7;top:0;left:0;width:100%;height:100%;display:none;

顯示彈出層內容的主要有:postion:fixed;display:none;top:50%;left:50%;z-index:3;background-color:#fff

3.寫js,在$(function(){...});在頁面載入事件裡面寫按鈕的click事件,那麼就直接$("#content").fadeIn(200);$("#bg").fadeIn(200);顯示彈出層和遮罩

點擊遮罩任意位置隱藏層和遮罩那麼如下:$("#content").fadeOut(200);$("#bg").fadeOut(200);

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.