html里面自定义弹出窗口

摘要:
网页上的默认提示框或对话框通常很难看。您可以使用div掩码自定义对话框。1.定义按钮或链接(单击项目中的图像)2.设置隐藏的掩码层˂div=“

  网页上默认的提示框或对话框一般比较丑,可以利用div遮盖层来自定义对话框

  1.定义一个按钮或者链接(项目里面是通过点击一个图片)

    <img src="http://t.zoukankan.com/images/zz.gif" onclick="myalert('描述(限200字):')"/>

  2.设置隐藏的遮罩层 

    <div id="divResult"></div><div id="bg"></div>
    <div style="display: none">
      <div class="title">标题</div>
      <div class="list2">
        <p></p>
      </div>
      <div>
        <textarea style="80%;margin-left:5%"></textarea>
      </div>
      <div class="end">
        <center>
          <a href="https://tool.4xseo.com/article/187449.html" style="color:#000000; font-size:16px; margin-right:5%">确定</a>
          <a href="https://tool.4xseo.com/article/187449.html" style="color:#000000; font-size:16px; margin-left:5%">取消</a>
        </center>
      </div>
    </div>

  3.用css设定自己的通用样式

    .box
      {
        position: absolute;
         250px;
        left: 50%;
        height: auto;
        z-index: 100;
        background-color: #fff;
        border: 1px solid rgb(0,153,153);
        /*padding: 1px;*/
       }

      .box div.title
      {
        height: 35px;
        font-size: 16px;
        background-color: #099;
        position: relative;
        padding-left: 10px;
        line-height: 35px;
        color: #fff;
      }

      .box div.title a
      {
        position: absolute;
        right: 5px;
        font-size: 16px;
        color: #fff;
      }

      .box div.list
      {
        min-height:60px;
        padding: 10px;
      }

      .box div.list p
      {
        height: 24px;
        line-height: 60px;
        font-size:14px;
      }

      .box div.end
      {
        min-height:30px;
        padding: 5px;
      }


    #bg
    {
      background-color: #666;
      position: absolute;
      z-index: 99;
      left: 0;
      top: 0;
      display: none;
       100%;
      height: 100%;
      opacity: 0.5;
      filter: alpha(opacity=50);
      -moz-opacity: 0.5;
      }

  4.编写myalert

    function myalert(msg) {

      $("#bg").css({
      display: "block", //height:$(document).height()
      height: "100%",
      position: "fixed"
      });
      var $box = $('.box');
      $box.css({
      //设置弹出层距离左边的位置
      left: ($("body").width() - $box.width()) / 2 + "px",
      //设置弹出层距离上面的位置
      top: ($(window).height() - $box.height()) / 2 - $(window).scrollTop() - $box.height() + "px",
      display: "block"
      }).find("p").html(msg);
    }

  

免责声明:文章转载自《html里面自定义弹出窗口》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇15、JDBC-CallableStatement使用sqlmap中tamper脚本绕过waf下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

flex布局最后一行列表左对齐的N种方法

一、justify-content对齐问题描述 在CSS flex布局中,justify-content属性可以控制列表的水平对齐方式,例如space-between值可以实现两端对齐。 但是,如果最后一行的列表的个数不满,则就会出现最后一行没有完全垂直对齐的问题。 如下代码: .container {display:flex;justify-conten...

taro: RichText 显示文章图片自适应

const __html = ` <p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; border: 0px; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, YaHei,...

使用swiper.js实现移动端tab切换

在项目中遇到的,要实现tab切换,我用的是swiper.js 官网:http://www.swiper.com.cn/api/start/new.html 1 <!DOCTYPE html> 2 <html lang="zh"> 3 <head> 4 <meta charset="UTF-...

安卓手机!用swiper做轮播效果,两张图片之间会有一个像素的空白

只要为swiper的父元素设置margin padding,或者用flex布局,让其居中,两个图片之间都会一个像素的空隙! 解决办法是,想让banner处于什么样的位置!就绝对定位就好了! 为什么会造成这样的原因没有查明白! 如下: 如果想要为swiper轮播的图片添加圆角时,一般都会直接给swpier上直接加border-radius,但是会发现不起作用...

js-实现鼠标滑轮滚动实现换页

html页面: 1 <!--首页一--> 2 <div id="nav_div1"><div class="nav_size"></div></div> 3 4 <!--首页二--> 5 <div id="nav_div2"></div> 6 7 <!...

Android开发之玩转FlexboxLayout布局

在这之前,我曾认真的研究过鸿洋大神的Android 自定义ViewGroup 实战篇 -> 实现FlowLayout,按照大神的思路写出了一个流式布局,所有的东西都是难者不会会者不难,当自己能自定义流式布局的时候就会觉得这东西原来很简单了。如果各位小伙伴也看过那篇文章的话,应该知道自定义流式布局还是非常麻烦的,不过Google今年开源了新的容器,就是...