栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

JavaScript实现拖动对话框效果的实现代码

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

JavaScript实现拖动对话框效果的实现代码

代码实现:





  
  
  document
  
    * {
      margin: 0;
      top: 0;
    }
    
    .login-btn {
      width: 50px;
      height: 50px;
      line-height: 50px;
      font-size: 16px;
      text-align: center;
      margin: 100px auto;
      background-color: #1E1E1E;
      color: white;
      border-radius: 50%;
    }
    
    .login-btn:hover {
      cursor: pointer;
      background-color: #323233;
      box-shadow: 3px 3px 10px rgba(0, 0, 0, .3);
    }
    
    .bg {
      display: none;
      width: 100%;
      height: 100%;
      position: fixed;
      top: 0;
      left: 0;
      background-color: rgba(0, 0, 0, .4);
    }
    
    .login {
      display: none;
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 300px;
      height: 200px;
      background-color: #1E1E1E;
      box-shadow: 4px 4px 15px rgba(0, 0, 0, .3);
    }
    
    .hd {
      position: relative;
      width: 100%;
      height: 26px;
      background-color: #323233;
    }
    
    .hd:hover {
      cursor: move;
    }
    
    .close {
      position: absolute;
      top: 3px;
      right: 5px;
      width: 20px;
      height: 20px;
      background-color: red;
      text-align: center;
      line-height: 20px;
      border-radius: 50%;
      box-shadow: 0 0 5px rgba(0, 0, 0, .7) inset;
    }
    
    .close:hover {
      background-color: yellow;
      cursor: pointer;
    }
  



  点击
  
  
    
      ×
    
  
  


实现效果:

点击点击按钮,弹出对话框。
按住对话框顶部并移动,实现拖动效果。
点击对话框右上角×,关闭对话框。

到此这篇关于Javascript实现拖动对话框效果的实现代码的文章就介绍到这了,更多相关js拖动对话框内容请搜索考高分网以前的文章或继续浏览下面的相关文章希望大家以后多多支持考高分网!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/68319.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号