移动DIV悬浮框

本文介绍了如何使用HTML和CSS创建移动悬浮框,包括添加CSS样式、编写页面样式和应用JavaScript来实现动态效果。
摘要由CSDN通过智能技术生成

1、首先添加CSS样式


        .ui-dialog{
            width: 450px;height: 180px;
            z-index: 9000;
            border: 1px solid #D5D5D5;background: #fff;
            overflow-y: auto;
        }

        .ui-dialog a{text-decoration: none;}

        .ui-dialog-title{
            height: 20px;line-height: 48px; padding:0px 20px;color: #535353;font-size: 16px;
            border-bottom: 1px solid #efefef;background: white;
            cursor: move;
            width: 508px;
        }
        .ui-dialog-content{
            padding: 15px 20px;
            width: 460px;
            overflow: auto;
        }

2、书写页面样式

<div class="ui-dialog" id="dialogMove" onselectstart='return false;' style="bottom:0%;right:0%">
    <div class="ui-dialog-title" id="dialogDrag"  onselectstart="return false;" style="margin-left: -60px" >
    你的标题显示的内
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是HTML和CSS代码,可以实现鼠标悬浮和手机长按时在上方悬浮显示提示: ```html <!DOCTYPE html> <html> <head> <title>Hover and Long Press Tooltip Demo</title> <style> .container { position: relative; width: 200px; height: 200px; background-color: #eee; margin: 50px auto; padding: 20px; text-align: center; } .tooltip { position: absolute; top: -30px; left: 50%; transform: translateX(-50%); background-color: #333; color: #fff; padding: 5px; border-radius: 5px; display: none; } .container:hover .tooltip { display: block; } .container.longpress .tooltip { display: block; } </style> </head> <body> <div class="container"> <h1>Hover and Long Press Tooltip Demo</h1> <div class="tooltip">This is a tooltip!</div> </div> <script> var container = document.querySelector('.container'); var timeout; container.addEventListener('touchstart', function(event) { timeout = setTimeout(function() { container.classList.add('longpress'); }, 500); }); container.addEventListener('touchend', function(event) { clearTimeout(timeout); container.classList.remove('longpress'); }); </script> </body> </html> ``` 这段代码定义了一个容器 `container`,其中包含一个标题和一个提示。提示使用了绝对定位,放在容器的上方,初始时隐藏。当鼠标悬浮容器或者长按容器时,提示就会显示出来。 注意,为了支持手机长按事件,这段代码还包含了一些JavaScript代码,可以监听 `touchstart` 和 `touchend` 事件,并根据长按持续时间来判断是否需要显示提示
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值