弹出浮动页面html怎么写,C# 浮动窗体实现(自定义弹出窗口)

c1f763503cec9bcbc024a38931c2b299.png

e411cb4c2d67fccd97cbec4fabdf633e.png

资源下载此资源下载价格为3D币,请先登录

资源文件列表

FmChild.Designer.cs , 6187

FmChild.resx , 7267

FmMDI.cs , 7680

FmMDI.Designer.cs , 22304

FmMDI.resx , 9452

PopupApp.csproj , 5371

Program.cs , 432

bin/Debug/PopupApp.exe , 145920

bin/Debug/PopupApp.pdb , 142848

bin/Debug/PopupApp.vshost.exe , 11608

FloatDemos/CalcDemo.cs , 1812

FloatDemos/CalcDemo.Designer.cs , 11765

FloatDemos/CalcDemo.resx , 5817

FloatDemos/ColorDemo.cs , 561

FloatDemos/ColorDemo.Designer.cs , 13503

FloatDemos/ColorDemo.resx , 5817

FloatDemos/FloatLayerBase.cs , 21849

FloatDemos/InputDemo.cs , 439

FloatDemos/InputDemo.Designer.cs , 7464

FloatDemos/InputDemo.resx , 5817

FloatDemos/NumInputDemo.cs , 427

FloatDemos/NumInputDemo.Designer.cs , 3273

FloatDemos/NumInputDemo.resx , 5817

FloatDemos/TipDemo.cs , 436

FloatDemos/TipDemo.Designer.cs , 4449

FloatDemos/TipDemo.resx , 149166

obj/x86/Debug/AhDung.FmChild.resources , 1126

obj/x86/Debug/AhDung.FmMDI.resources , 2381

obj/x86/Debug/AhDung.PopupDemos.ColorDemo.resources , 180

obj/x86/Debug/AhDung.PopupDemos.ColorPopDemo.resources , 180

obj/x86/Debug/AhDung.PopupDemos.TestDemo.resources , 180

obj/x86/Debug/AhDung.Properties.Resources.resources , 1784

obj/x86/Debug/AhDung.WinForm.Controls.CalcPopDemo.resources , 180

obj/x86/Debug/AhDung.WinForm.Controls.InputPopDemo.resources , 180

obj/x86/Debug/AhDung.WinForm.Controls.NumInputPopDemo.resources , 180

obj/x86/Debug/AhDung.WinForm.Controls.TipPopDemo.resources , 95850

obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache , 9500

obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache , 5128

obj/x86/Debug/PopupApp.csproj.FileListAbsolute.txt , 2187

obj/x86/Debug/PopupApp.csproj.GenerateResource.Cache , 2126

obj/x86/Debug/PopupApp.exe , 145920

obj/x86/Debug/PopupApp.pdb , 142848

obj/x86/Debug/TempPE/Properties.Resources.Designer.cs.dll , 4608

Properties/AssemblyInfo.cs , 1348

Properties/Resources.Designer.cs , 3586

Properties/Resources.resx , 6575

Resources/Pen24.png , 579

Resources/tick.png , 582

ColorPicker.cs , 891

FmChild.cs , 1537

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是使用 JS 实现弹出浮动窗口的详细步骤: 1. HTML 结构 首先,我们需要在 HTML 中添加一个按钮,用于触发弹出浮动窗口的事件。同时,为了方便后续操作,我们需要在 HTML 中添加一个空的 div 元素,用于存放弹出浮动窗口的内容。 ```html <button id="open-btn">打开浮动窗口</button> <div id="float-window"></div> ``` 2. CSS 样式 接下来,我们需要为浮动窗口添加样式。这里我们使用绝对定位来实现浮动效果,同时添加一些基本的样式,如背景颜色、边框样式等。 ```css #float-window { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 400px; height: 300px; background-color: #fff; border: 1px solid #ccc; display: none; /* 默认隐藏 */ } ``` 3. JS 代码 最后,我们需要使用 JS 代码来实现弹出浮动窗口的功能。具体步骤如下: 1. 获取按钮元素和浮动窗口元素,并添加事件监听器。 ```javascript var openBtn = document.getElementById('open-btn'); var floatWindow = document.getElementById('float-window'); openBtn.addEventListener('click', function() { floatWindow.style.display = 'block'; }); ``` 2. 实现拖拽效果。 ```javascript var isDragging = false; // 是否正在拖动 var mouseOffset = { x: 0, y: 0 }; // 鼠标相对于浮动窗口的偏移量 floatWindow.addEventListener('mousedown', function(e) { isDragging = true; mouseOffset.x = e.pageX - floatWindow.offsetLeft; mouseOffset.y = e.pageY - floatWindow.offsetTop; }); document.addEventListener('mousemove', function(e) { if (isDragging) { floatWindow.style.left = e.pageX - mouseOffset.x + 'px'; floatWindow.style.top = e.pageY - mouseOffset.y + 'px'; } }); document.addEventListener('mouseup', function() { isDragging = false; }); ``` 3. 实现关闭效果。 ```javascript var closeBtn = document.createElement('div'); closeBtn.innerHTML = '关闭'; closeBtn.style.position = 'absolute'; closeBtn.style.top = '10px'; closeBtn.style.right = '10px'; floatWindow.appendChild(closeBtn); closeBtn.addEventListener('click', function() { floatWindow.style.display = 'none'; }); ``` 最终的 JS 代码如下: ```javascript var openBtn = document.getElementById('open-btn'); var floatWindow = document.getElementById('float-window'); openBtn.addEventListener('click', function() { floatWindow.style.display = 'block'; }); var isDragging = false; // 是否正在拖动 var mouseOffset = { x: 0, y: 0 }; // 鼠标相对于浮动窗口的偏移量 floatWindow.addEventListener('mousedown', function(e) { isDragging = true; mouseOffset.x = e.pageX - floatWindow.offsetLeft; mouseOffset.y = e.pageY - floatWindow.offsetTop; }); document.addEventListener('mousemove', function(e) { if (isDragging) { floatWindow.style.left = e.pageX - mouseOffset.x + 'px'; floatWindow.style.top = e.pageY - mouseOffset.y + 'px'; } }); document.addEventListener('mouseup', function() { isDragging = false; }); var closeBtn = document.createElement('div'); closeBtn.innerHTML = '关闭'; closeBtn.style.position = 'absolute'; closeBtn.style.top = '10px'; closeBtn.style.right = '10px'; floatWindow.appendChild(closeBtn); closeBtn.addEventListener('click', function() { floatWindow.style.display = 'none'; }); ``` 这样,我们就完成了使用 JS 实现弹出浮动窗口的功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值