全网整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:400-708-3566

jQuery tip提示插件(实例分享)

先声明,我也是学了某位大神的...

效果图:

代码如下:

<!DOCTYPE html>
<html>
<head lang="en">
 <meta charset="UTF-8">
 <title>document</title>
 <style>
  .tip{
   width: 200px;
   text-align: center;
   position: relative;
   border:1px solid #ccc;
   height: 50px;
   line-height: 50px;
   left: 50%;
   margin-top: 50px;
   transform: translateX(-50%);
  }
  .tip-container{
   position: absolute;
   box-shadow: 2px 2px 5px #f9f9f9;
   z-index: 999;
   display: none;
  }
  .tip-container .tip-point-top,
  .tip-container .tip-point-bottom,
  .tip-container .tip-point-left,
  .tip-container .tip-point-right{
   border:1px solid #dcdcdc;
   position: relative;
   background: white;
  }
  .tip-content{
   padding:5px 10px;
   background: white;
   font-size: 12px;
   line-height: 1.7;
   font-family: "Helvetica Neue",Helvetica,Arial,"MicroSoft YaHei";
  }
  .tip-container .tip-point-top::after,
  .tip-container .tip-point-top::before,
  .tip-container .tip-point-bottom::after,
  .tip-container .tip-point-bottom::before{
   content:"";
   position: absolute;
   border:solid transparent;
   left: 50%;
   width: 0;
   height: 0;
   transform: translate3d(-50%,0,0);
   -webkit-transform: translate3d(-50%,0,0);
  }

  .tip-container .tip-point-right::after,
  .tip-container .tip-point-right::before,
  .tip-container .tip-point-left::after,
  .tip-container .tip-point-left::before{
   content:"";
   position: absolute;
   border:solid transparent;
   top: 50%;
   width: 0;
   height: 0;
   transform: translate3d(0,-50%,0);
   -webkit-transform: translate3d(0,-50%,0);

  }
  /*tip-point-top*/
  .tip-container .tip-point-top::after{
   border-top-color: #fff;
   top: 100%;
   border-width: 5px;
  }
  .tip-container .tip-point-top::before {
   border-top-color: #dcdcdc;
   top: 100%;
   border-width: 7px;
  }
  /*tip-point-bottom*/
  .tip-container .tip-point-bottom::after{
   border-bottom-color: #fff;
   bottom: 100%;
   border-width: 5px;
  }
  .tip-container .tip-point-bottom::before {
   border-bottom-color: #dcdcdc;
   bottom: 100%;
   border-width: 7px;
  }
  /*tip-point-right*/
  .tip-container .tip-point-right::after{
   border-right-color: #fff;
   right: 100%;
   border-width: 5px;
  }
  .tip-container .tip-point-right::before {
   border-right-color: #dcdcdc;
   right: 100%;
   border-width: 7px;
  }
  /*tip-point-left*/
  .tip-container .tip-point-left::after{
   border-left-color: #fff;
   left: 100%;
   border-width: 5px;
  }
  .tip-container .tip-point-left::before {
   border-left-color: #dcdcdc;
   left: 100%;
   border-width: 7px;
  }
 </style>
</head>
<body>
<div class="tip" data-tip="寂寞的天下着忧郁的雨" data-mode="top">天堂不寂寞</div>
<div class="tip" data-tip="天堂不寂寞" data-mode="bottom">寂寞的天下着忧郁的雨</div>
<div class="tip" data-tip="寂寞的天下着忧郁的雨" data-mode="right">寂寞的天下着忧郁的雨</div>
<div class="tip" data-tip="天堂不寂寞" data-mode="left">寂寞的天下着忧郁的雨</div>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<script>
 /**
  * Created by zxhuan (you@example.com)
  * Date: 2016/11/28
  * Time: 11:14
  */
 ;
 (function ($,window,document,undefined) {
  var modePos;
  $.fn.tip = function (options) {
   var set = $.extend({
    "mode": "bottom",
    "speed": 300,
    "tipText":"提示内容"
   }, options);
   if(!modePos){
    //策略模式
    //算法
    modePos = {
     top: function (t, tip) {
      return {
       left: t.offset().left + (t.width() - tip.width()) / 2 + "px",
       top: t.offset().top - tip.height() - 12 + "px"
      }
     },
     bottom:function(t, tip){
      return {
       left: this.top(t, tip).left,
       top: t.offset().top + t.height() + 12 + "px"
      }
     },
     left:function(t, tip){
      return{
       left:t.offset().left - tip.width()-12+ "px",
       top:t.offset().top +(t.height()-tip.height())/2+"px"
      }
     },
     right:function(t, tip){
      return{
       left:t.offset().left +t.width()+12+ "px",
       top:t.offset().top +(t.height()-tip.height())/2+"px"
      }
     }
    };
   }
   function Tip(_this){
    var _that = $(_this);
    var _mode = set.mode;
    var tipText=set.tipText;
    var _tip=".tip-container";
    if (_that.data("mode")) {
     _mode = _that.data("mode");
    }
    if(_that.data("tip")){
     tipText = _that.data("tip");
    }
    _that.css("cursor", "pointer");
    _that.hover(function () {
     var _tipHtml = '<div class="tip-container"><div class="tip-point-' + _mode + '"><div class="tip-content">' + tipText + '</div></div></div>';
     _that.removeAttr("title alt");
     $("body").append(_tipHtml);
     $(_tip).css(modePos[_mode](_that,$(_tip))).fadeIn(set.speed);
    }, function () {
     $(".tip-container").remove();
    });
   }
   return this.each(function () {
    return new Tip(this);
   });
  }
 })(jQuery,window,document);
 $(".tip").tip();
</script>
</body>
</html>

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!


# jquery  # tip提示插件  # tip  # 插件  # qTip2 精致的基于jQuery提示信息插件  # jQuery带箭头提示框tooltips插件集锦  # 编写自己的jQuery提示框(Tip)插件  # jquery-tips悬浮提示插件分享  # jquery.cvtooltip.js 基于jquery的气泡提示插件  # jQuery插件Tooltipster实现漂亮的工具提示  # 属于你的jQuery提示框(Tip)插件  # 基于jQuery Tipso插件实现消息提示框特效  # jQuery消息提示框插件Tipso  # poshytip 基于jquery的 插件 主要用于显示微博人的图像和鼠标提示等  # 不寂寞  # 大神  # 学了  # 我也是  # box  # absolute  # container  # top  # shadow  # translateX  # left  # line  # transform  # height  # margin  # index  # padding  # content  # font  # size 


相关文章: 网站制作大概多少钱一个,做一个平台网站大概多少钱?  免费制作海报的网站,哪位做平面的朋友告诉我用什么软件做海报比较好?ps还是cd还是ai这几个软件我都会些我是做网页的?  TestNG的testng.xml配置文件怎么写  Thinkphp 中 distinct 的用法解析  如何在新浪SAE免费搭建个人博客?  智能起名网站制作软件有哪些,制作logo的软件?  广东企业建站网站优化与SEO营销核心策略指南  详解ASP.NET 生成二维码实例(采用ThoughtWorks.QRCode和QrCode.Net两种方式)  ,怎么在广州志愿者网站注册?  沈阳制作网站公司排名,沈阳装饰协会官方网站?  企业宣传片制作网站有哪些,传媒公司怎么找企业宣传片项目?  微信网站制作公司有哪些,民生银行办理公司开户怎么在微信网页上查询进度?  成都网站制作公司哪家好,四川省职工服务网是做什么用?  网站专业制作公司,网站编辑是做什么的?好做吗?工作前景如何?  *服务器网站为何频现安全漏洞?  如何选择可靠的免备案建站服务器?  如何用PHP工具快速搭建高效网站?  如何选择服务器才能高效搭建专属网站?  广州建站公司哪家好?十大优质服务商推荐  利用JavaScript实现拖拽改变元素大小  如何在宝塔面板中创建新站点?  C++时间戳转换成日期时间的步骤和示例代码  东莞市网站制作公司有哪些,东莞找工作用什么网站好?  如何生成腾讯云建站专用兑换码?  如何在云虚拟主机上快速搭建个人网站?  如何通过主机屋免费建站教程十分钟搭建网站?  代刷网站制作软件,别人代刷火车票靠谱吗?  官网自助建站系统:SEO优化+多语言支持,快速搭建专业网站  html制作网站的步骤有哪些,iapp如何添加网页?  建站主机核心功能解析:服务器选择与网站搭建流程指南  详解免费开源的DotNet二维码操作组件ThoughtWorks.QRCode(.NET组件介绍之四)  定制建站方案优化指南:企业官网开发与建站费用解析  佛山网站制作系统,佛山企业变更地址网上办理步骤?  为什么Go需要go mod文件_Go go mod文件作用说明  公司门户网站制作流程,华为官网怎么做?  如何在万网自助建站中设置域名及备案?  建站之星各版本价格是多少?  建站主机CVM配置优化、SEO策略与性能提升指南  如何通过cPanel快速搭建网站?  C++用Dijkstra(迪杰斯特拉)算法求最短路径  建站之星安装需要哪些步骤及注意事项?  建站之星如何实现五合一智能建站与营销推广?  一键网站制作软件,义乌购一件代发流程?  内部网站制作流程,如何建立公司内部网站?  如何选购建站域名与空间?自助平台全解析  已有域名和空间,如何快速搭建网站?  宿州网站制作公司兴策,安徽省低保查询网站?  制作国外网站的软件,国外有哪些比较优质的网站推荐?  如何选择高性价比服务器搭建个人网站?  微网站制作教程,不会写代码,不会编程,怎么样建自己的网站? 

您的项目需求

*请认真填写需求信息,我们会在24小时内与您取得联系。