欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript+html5+css3自定義彈出窗口效果

 更新時間:2017年10月26日 14:26:19   作者:冷月葬殘花  
這篇文章主要為大家詳細(xì)介紹了javascript+html5+css3自定義彈出窗口效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了js自定義彈出窗口效果展示的具體代碼,供大家參考,具體內(nèi)容如下

效果圖:

源碼:

1.demo.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>自定義彈出窗口</title>
  <script type="text/javascript" src="js/myLayer.js"></script>
  <style type="text/css">
    button{
      width: 50px;
      height: 50px;
      border: 1px solid blue;
      background-color: blue;
      color: red;
      border-radius: 5px;
      -webkit-box-shadow: 2px 2px 2px gray;
      -moz-box-shadow: 2px 2px 2px gray ;
      box-shadow: 2px 2px 2px gray ;
    }
    button:hover{
      background-color: green;
      cursor: pointer;
    }
  </style>
  <script type="text/javascript">
    function openWindow() {
      new MyLayer({
        top:"10%",
        left:"10%",
        width:"80%",
        height:"80%",
        title:"我的標(biāo)題",
        content:"操作成功"
      }).openLayer();
    }
  </script>
</head>
<body>
  <button type="button" onclick="openWindow()">打開彈窗</button>
</body>
</html> 

2.myLayer.js

/**
 * Created by zhuwenqi on 2017/6/16.
 */
/**
 * @param options 彈窗基本配置信息
 * @constructor 構(gòu)造方法
 */
function MyLayer(options) {
  this.options = options ;
}
/**
 * 打開彈窗
 */
MyLayer.prototype.openLayer = function () {
  var background_layer = document.createElement("div");
  background_layer.style.display = "none";
  background_layer.style.position = "absolute";
  background_layer.style.top = "0px";
  background_layer.style.left = "0px";
  background_layer.style.width = "100%";
  background_layer.style.height = "100%";
  background_layer.style.backgroundColor = "gray";
  background_layer.style.zIndex = "1001";
  background_layer.style.opacity = "0.8" ;
  var open_layer = document.createElement("div");
  open_layer.style.display = "none";
  open_layer.style.position = "absolute";
  open_layer.style.top = this.options.top === undefined ? "10%" : this.options.top;
  open_layer.style.left = this.options.left === undefined ? "10%" :this.options.left;
  open_layer.style.width = this.options.width === undefined ? "80%" : this.options.width;
  open_layer.style.height = this.options.height === undefined ? "80%" : this.options.height;
  open_layer.style.border = "1px solid lightblue";
  open_layer.style.borderRadius = "15px" ;
  open_layer.style.boxShadow = "4px 4px 10px #171414";
  open_layer.style.backgroundColor = "white";
  open_layer.style.zIndex = "1002";
  open_layer.style.overflow = "auto";
  var div_toolBar = document.createElement("div");
  div_toolBar.style.textAlign = "right";
  div_toolBar.style.paddingTop = "10px" ;
  div_toolBar.style.backgroundColor = "aliceblue";
  div_toolBar.style.height = "40px";
  var span_title = document.createElement("span");
  span_title.style.fontSize = "18px";
  span_title.style.color = "blue" ;
  span_title.style.float = "left";
  span_title.style.marginLeft = "20px";
  var span_title_content = document.createTextNode(this.options.title === undefined ? "" : this.options.title);
  span_title.appendChild(span_title_content);
  div_toolBar.appendChild(span_title);
  var span_close = document.createElement("span");
  span_close.style.fontSize = "16px";
  span_close.style.color = "blue" ;
  span_close.style.cursor = "pointer";
  span_close.style.marginRight = "20px";
  span_close.onclick = function () {
    open_layer.style.display = "none";
    background_layer.style.display = "none";
  };
  var span_close_content = document.createTextNode("關(guān)閉");
  span_close.appendChild(span_close_content);
  div_toolBar.appendChild(span_close);
  open_layer.appendChild(div_toolBar);
  var div_content = document.createElement("div");
  div_content.style.textAlign = "center";
  var content_area = document.createTextNode(this.options.content === undefined ? "" : this.options.content);
  div_content.appendChild(content_area);
  open_layer.appendChild(div_content);
  document.body.appendChild(open_layer);
  document.body.appendChild(background_layer);
  open_layer.style.display = "block" ;
  background_layer.style.display = "block";
};

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Layui組件Table綁定行點擊事件和獲取行數(shù)據(jù)的方法

    Layui組件Table綁定行點擊事件和獲取行數(shù)據(jù)的方法

    今天小編就為大家分享一篇Layui組件Table綁定行點擊事件和獲取行數(shù)據(jù)的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-08-08
  • JS判斷鍵盤是否按的回車鍵并觸發(fā)指定按鈕點擊操作的方法

    JS判斷鍵盤是否按的回車鍵并觸發(fā)指定按鈕點擊操作的方法

    下面小編就為大家?guī)硪黄狫S判斷鍵盤是否按的回車鍵并觸發(fā)指定按鈕點擊操作的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-02-02
  • 深入了解JavaScript Promise

    深入了解JavaScript Promise

    這篇文章主要為大家介紹了JavaScript Promise,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助
    2021-12-12
  • 微信小程序開發(fā)問題之wx.previewImage

    微信小程序開發(fā)問題之wx.previewImage

    這篇文章主要給大家介紹了關(guān)于微信小程序開發(fā)問題之wx.previewImage的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-12-12
  • 禁用Tab鍵JS代碼兼容Firefox和IE

    禁用Tab鍵JS代碼兼容Firefox和IE

    這篇文章主要介紹了禁用Tab鍵的JS代碼兼容Firefox和IE,需要的朋友可以參考下
    2014-04-04
  • javascript:;與javascript:void(0)使用介紹

    javascript:;與javascript:void(0)使用介紹

    有時候我們在編寫js過程中,需要觸發(fā)事件而不需要返回值,那么就可能需要這樣的寫法
    2013-06-06
  • JS賦值、淺拷貝和深拷貝(數(shù)組和對象的深淺拷貝)實例詳解

    JS賦值、淺拷貝和深拷貝(數(shù)組和對象的深淺拷貝)實例詳解

    這篇文章主要介紹了JS賦值、淺拷貝和深拷貝,結(jié)合實例形式總結(jié)分析了JavaScript數(shù)組和對象的深淺拷貝相關(guān)概念、原理、操作技巧與使用注意事項,需要的朋友可以參考下
    2020-03-03
  • 使用原生js編寫一個簡單的框選功能方法

    使用原生js編寫一個簡單的框選功能方法

    這篇文章主要介紹了使用原生js編寫一個簡單的框選功能方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • 使用js實現(xiàn)單鏈解決前端隊列問題的方法

    使用js實現(xiàn)單鏈解決前端隊列問題的方法

    這篇文章主要介紹了使用js實現(xiàn)單鏈解決前端隊列問題的方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-02-02
  • 用JS實現(xiàn)飛機大戰(zhàn)小游戲

    用JS實現(xiàn)飛機大戰(zhàn)小游戲

    這篇文章主要為大家詳細(xì)介紹了用JS實現(xiàn)飛機大戰(zhàn)小游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-06-06

最新評論