网站悬浮窗漂浮

简介: 网站悬浮窗漂浮

网站悬浮窗漂浮


<html>
 <head> 
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  <title>Jerory's code</title> 
  <style>
  .float_x {
    cursor: pointer;
    color: #000;
    margin: 3 0 3 0;
    font-size: 12px;
    text-align: center;
    border: 1px solid gray;
    border-radius: 50%;
    width: 18px;
    height: 16px;
    margin-top: -113px;
    position: absolute;
    margin-left: 195px;
  }
  .float_div{
    position: absolute; 
    left: 311; top: 815;visibility :hidden;   
    border:0px solid #000; 
    width:200px; 
    height:100px;
  }
  .float_img{
    width:100%;height:100%; 
    cursor:pointer;
    border-radius:5px;
  }
  </style>
 </head> 
 <body> 
  <div id="img" class="float_div" onmouseover="clearInterval(interval)" onmouseout="interval = setInterval('changePos()', delay)" align="right"> 
   <img class="float_img" src="https://s2.ax1x.com/2019/11/12/M1l3l9.jpg" onclick="javascript:window.open('http://www.baidu.com');" onload="return imgzoom(this,550)" /> 
   <div class="float_x" onclick="clearInterval(interval);img.style.visibility = 'hidden'">
    X
   </div> 
  </div> 
    <script language="javascript">
    var xPos = document.body.clientWidth;
    //var yPos = document.body.clientHeight;
    var yPos = 20;
    var step = 1;
    var delay = 30;                     
    var height = 0;                     
    var Hoffset = 0;                    
    var Woffset = 0;                     
    var yon = 0;                    
    var xon = 0;                     
    var pause = true;                    
    var interval;                    
    img.style.top = yPos;                    
    function changePos() {                   
    width = document.body.clientWidth;                    
    height = document.body.clientHeight;                    
    Hoffset = img.offsetHeight;                    
    Woffset = img.offsetWidth;                   
    img.style.left = xPos + document.body.scrollLeft;                    
    img.style.top = yPos + document.body.scrollTop;                    
    if (yon) {                  
    yPos = yPos + step;                    
    }               
    else {             
    yPos = yPos - step;                    
    }            
    if (yPos < 0) {                  
    yon = 1;                    
    yPos = 0;                    
    }                  
    if (yPos >= (height - Hoffset)) {                    
    yon = 0;                    
    yPos = (height - Hoffset);                     
    }                  
    if (xon) {                    
    xPos = xPos + step;                    
    }                 
    else {                 
    xPos = xPos - step;                   
    }                  
    if (xPos < 0) {                    
    xon = 1;                   
    xPos = 0;                   
    }         
    if (xPos >= (width - Woffset)) {                    
    xon = 0;           
    xPos = (width - Woffset);                    
    }                    
    }
    function start() {                    
    img.style.visibility = "visible";                  
    interval = setInterval('changePos()', delay);                    
    }              
    start();  
  </script>  
 </body>
</html>


目录
相关文章
HMI-43-【节能模式】顶部标题栏和底部信息栏及灯光及启动动画
今天来实现以下节能模式的Title底部信息栏,灯光系统,以及启动动画。
HMI-43-【节能模式】顶部标题栏和底部信息栏及灯光及启动动画
|
6月前
仿百度地图上拉下滑抽屉盒
仿百度地图上拉下滑抽屉盒
18 0
|
9月前
|
开发框架 iOS开发
手机软键盘弹起导致页面变形的一种解决方案
手机软键盘弹起导致页面变形的一种解决方案
315 0
|
9月前
|
C++ Python
|
9月前
|
存储 C++ Python
C++复刻:[流光按钮]+[悬浮波纹按钮]
[流光按钮]+[悬浮波纹按钮]
113 0
|
容器
利用CustomScrollView实现更有趣的滑动效果
本篇介绍了 CustomScrollView 的基本用法以及 SliverAppBar 的使用,通过 SliverAppBar 可以让导航栏的滑动更有趣。
718 0
利用CustomScrollView实现更有趣的滑动效果
|
定位技术 Android开发
Android仿饿了么地图滑动悬停华丽效果
Android仿饿了么地图滑动悬停华丽效果
332 0
Android仿饿了么地图滑动悬停华丽效果
直播带货系统,滚动视图,上滑隐藏,下滑显示
直播带货系统,滚动视图,上滑隐藏,下滑显示
240 0
|
Java Android开发
PopupWindow 使用详解(二) Popwindow 制作常见花哨效果
PopupWindow 详解的第二篇,制作一些相对简单的效果。
4726 0
|
JavaScript
jquery实现的让图片在网页的可视区域里四处漂浮的效果
  本文分享给大家一个用jquery开发的图片漂浮效果。 jquery图片漂浮效果,常见的就是网页里四处漂来漂去的广告了,漂到边缘时还会反弹和拐弯。 下面来看具体的代码,先看要实现漂亮效果的这个jquery插件的源码: (function($){ $.
1622 0