網站首頁 編程語言 正文
本文實例為大家分享了jquery實現界面點擊按鈕彈出懸浮框的具體代碼,供大家參考,具體內容如下
首先定義兩個div:
一個是背景,一個是懸浮窗。
<input id="Button1" type="button" value="點擊彈出層"/>? ? ? ? ?? ??? ?<!--彈出層時背景層DIV--> ?? ??? ?<div id="fade" class="black_overlay"></div> ?? ??? ?<!-- 編輯框 可以加自己的樣式 --> ?? ??? ?<div id="MyDiv" class="white_content"> ?? ??? ??? ?點擊陰影處退出!!! </div>
css樣式:
<style> ?? ??? ??? ?.black_overlay { ? ? ? ? ? ? display: none; ? ? ? ? ? ? position: absolute; ? ? ? ? ? ? top: 0%; ? ? ? ? ? ? left: 0%; ? ? ? ? ? ? width: 100%; ? ? ? ? ? ? height: 100%; ? ? ? ? ? ? background-color: black; ? ? ? ? ? ? z-index: 1001; ? ? ? ? ? ? -moz-opacity: 0.8; ? ? ? ? ? ? opacity: .80; ? ? ? ? ? ? filter: alpha(opacity=80); ? ? ? ? } ? ? ? ? .white_content { ? ? ? ? ? ? display: none; ? ? ? ? ? ? position: absolute; ? ? ? ? ? ? top: 10%; ? ? ? ? ? ? left: 10%; ? ? ? ? ? ? width: 80%; ? ? ? ? ? ? height: 80%; ? ? ? ? ? ? border: 16px solid lightblue; ? ? ? ? ? ? background-color: white; ? ? ? ? ? ? z-index: 1002; ? ? ? ? ? ? overflow: auto; ? ? ? ? } ? ? ? ? .white_content_small { ? ? ? ? ? ? display: none; ? ? ? ? ? ? position: absolute; ? ? ? ? ? ? top: 20%; ? ? ? ? ? ? left: 30%; ? ? ? ? ? ? width: 40%; ? ? ? ? ? ? height: 50%; ? ? ? ? ? ? border: 16px solid lightblue; ? ? ? ? ? ? background-color: white; ? ? ? ? ? ? z-index: 1002; ? ? ? ? ? ? overflow: auto; ? ? ? ? } </style>
jquery方法:
<script type="text/javascript"> ?? ??? ?$("#Button1").click(function() { ?? ??? ??? ?document.getElementById("MyDiv").style.display = 'block'; ?? ??? ??? ?document.getElementById("fade").style.display = 'block'; ?? ??? ??? ?var bgdiv = document.getElementById("fade"); ?? ??? ??? ?bgdiv.style.width = document.body.scrollWidth; ?? ??? ??? ?$("#fade").height($(document).height()); ?? ??? ?}); ?? ??? ?//關閉彈出層 ?? ??? ?$("#fade").click(function() { ?? ??? ??? ?document.getElementById("MyDiv").style.display = 'none'; ?? ??? ??? ?document.getElementById("fade").style.display = 'none'; ?? ??? ?}); </script>
效果圖:
原文鏈接:https://blog.csdn.net/bing_bg/article/details/104934223
相關推薦
- 2022-12-21 Redis數據庫原理深入刨析_Redis
- 2022-02-11 SQL server 數據庫導入(附加)和分離 && 數據庫分離之后位置 &
- 2022-04-27 為ABP框架增加日志組件與依賴注入服務_基礎應用
- 2022-10-11 Filter過濾器和Listener監聽器
- 2022-11-03 Python中的def?__init__(?)函數_python
- 2022-12-01 RFO?SIG之openEuler?AWS?AMI?制作詳解_云其它
- 2022-04-01 exception occurred during ITK-SNAP startup itk-sn
- 2022-12-05 go?code?review?代碼調試_Golang
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支