当鼠标hover的时候,使用tip将overflow:hidden隐藏的文字显示完全
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- <style type="text/css">
- #dhtmltooltip{
- position: absolute;
- left: -300px;
- width: 150px;
- border: 1px solid black;
- padding: 2px;
- background-color: lightyellow;
- visibility: hidden;
- z-index: 100;
- filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135);
- }
- #dhtmlpointer{
- position:absolute;
- left: -300px;
- z-index: 101;
- visibility: hidden;
- }
- .myTest{width: 100px;overflow: hidden;white-space: nowrap;text-overflow:ellipsis;}
- </style>
- </head>
- <body>
- <div class="myTest" onMouseover="ddrivetip($(this).text(), 300,'red')";
- onMouseout="hideddrivetip()">ssssssss</div>
- </body>
- <script type="text/javascript" src="jquery-1.11.3.min.js"></script>
- <script type="text/javascript">
- var offsetfromcursorX=12 //Customize x offset of tooltip
- var offsetfromcursorY=10 //Customize y offset of tooltip
- var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
- var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).
- document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
- document.write('<img id="dhtmlpointer">') //write out pointer image
- var ie=document.all
- var ns6=document.getElementById && !document.all
- var enabletip=false
- if (ie||ns6)
- var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
- var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""
- function ietruebody(){
- return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
- }
- function ddrivetip(thetext, thewidth, thecolor){
- if (ns6||ie){
- if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
- if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
- tipobj.innerHTML=thetext
- //下面这段是用来判断,当字符串大于多少时才出现tip框。
- var len = 0;
- for (var i=0; i<thetext.length; i++) {
- //单字节加1
- if (thetext[i].match(/[^\x00-\xff]/ig) != null) {
- len+=2;
- }
- else {
- len++;
- }
- }
- if(len > 10)
- enabletip=true
- return false
- }
- }
- function positiontip(e){
- if (enabletip){
- var nondefaultpos=false
- var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
- var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
- //Find out how close the mouse is to the corner of the window
- var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
- var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20
- var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
- var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY
- var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000
- //if the horizontal distance isn't enough to accomodate the width of the context menu
- if (rightedge<tipobj.offsetWidth){
- //move the horizontal position of the menu to the left by it's width
- tipobj.style.left=curX-tipobj.offsetWidth+"px"
- nondefaultpos=true
- }
- else if (curX<leftedge)
- tipobj.style.left="5px"
- else{
- //position the horizontal position of the menu where the mouse is positioned
- tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
- pointerobj.style.left=curX+offsetfromcursorX+"px"
- }
- //same concept with the vertical position
- if (bottomedge<tipobj.offsetHeight){
- tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
- nondefaultpos=true
- }
- else{
- tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
- pointerobj.style.top=curY+offsetfromcursorY+"px"
- }
- tipobj.style.visibility="visible"
- if (!nondefaultpos)
- pointerobj.style.visibility="visible"
- else
- pointerobj.style.visibility="hidden"
- }
- }
- function hideddrivetip(){
- if (ns6||ie){
- enabletip=false
- tipobj.style.visibility="hidden"
- pointerobj.style.visibility="hidden"
- tipobj.style.left="-1000px"
- tipobj.style.backgroundColor=''
- tipobj.style.width=''
- }
- }
- document.onmousemove=positiontip
- </script>
- </html>
当鼠标hover的时候,使用tip将overflow:hidden隐藏的文字显示完全的更多相关文章
- table 控制单双行颜色以及鼠标hover颜色 table光棒
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 鼠标hover某个元素时其属性表现Css transition 过渡效果(以宽高属性居中放大为例)
<!DOCTYPE html> <html> <head> </head> <body id="body"> <! ...
- Echarts 地图(map)插件之 鼠标HOVER和tooltip自定义提示框
[自行修改 "引号"] 一.鼠标HOVER时的事件: 参照官方文档解释, 可以看出这款插件有丰富的鼠标事件可供选择: 调用鼠标HOVER事件的方法很简单,只需把以下代码放到char ...
- HTML5鼠标hover的时候图片放大的效果展示
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- 鼠标HOVER时区块动画旋转变色的CSS3样式掩码
鼠标hover时区块动画旋转变色的css3样式掩码<!DOCTYPE html> <html> <head> <meta charset="utf- ...
- 简单的圆形图标鼠标hover效果 | CSS3教程
演示 本教程将和大将分享一些简单的圆形图标在鼠标hover时的动画效果.这种效果在不少时尚的酷站上都有.本教程中的例子主要是利用在a元素的伪元素上使用CSS transitions和animation ...
- 鼠标hover事件
JS: // ========== // = 鼠标hover事件 = // ========== function showHide (btn,box) { $(btn).hover(function ...
- 如何在鼠标hover时改变标注的样式
如何在鼠标hover时改变标注的样式? ---------------- 教程 ----------------------- 首先创建1张地图 //初始化地图对象,加载地图 var map ...
- 经典的 div + css 鼠标 hover 下拉菜单
经典的 div + css 鼠标 hover 下拉菜单 效果图: 源码: <html> <head> <meta charset="utf-8"> ...
随机推荐
- dubbo的本地存根
在消费者创建存根类 修改消费者XML 也可以修改消费者注解
- 对《The future of ReactiveCocoa》的一些思考
前言 我以为 第一次接触 swift 语言时,看到函数的表示形式如下: func fun(num: Int) -> Int { return num + 1 } let f = fun(1) 和 ...
- string.Format字符串格式化说明(转)
string.Format字符串格式化说明 www.111cn.net 编辑:Crese 来源:转载 先举几个简单的应用案例: 1.格式化货币(跟系统的环境有关,中文系统默认格式化人民币,英文系统 ...
- PyTorch基础——预测共享单车的使用量
预处理实验数据 读取数据 下载数据 网盘链接:https://pan.baidu.com/s/1n_FtZjAswWR9rfuI6GtDhA 提取码:y4fb #导入需要使用的库 import num ...
- J. Stone game(背包问题)
题:https://nanti.jisuanke.com/t/41420 定义 dp[x][y] 表示第 x 个数到最后一个数能组成和为 y 的方案数 #include<bits/stdc++. ...
- window下mysql安装步骤
1. 官网下载mysql zip包 2. 解压后再D:\database\mysql\mysql-5.7.26-winx64下添加my.ini文件,文件内容如下: [mysql]# 设置mysql客户 ...
- Java常用基本类库总结2
1.File类的重要方法(Java中文件.文件夹都用File类表示) 构造函数: public File(String pathname);//根据指定的路径创建File对象. public File ...
- 变得“不正经”的CES,竟然越来越好玩了
在所有科技界的展会中,国人最熟悉的当属CES.作为科技行业的风向指示标,CES一直在扮演着重要的潮流指引者角色.不过,现在的CES似乎变得越来越"不正经"了!原本CES是国际消费类 ...
- BigDecimal不整除的一个异常java.lang.ArithmeticException
转载地址:http://blog.csdn.net/jobjava/article/details/6764623 金额的数据类型是BigDecimal 通过BigDecimal的divide方法进行 ...
- Yii框架的学习指南(策码秀才篇)1-1 如何认识Yii framework
Yii的框架和其他框架的区别在于:它是更加 快速,安全,专业的PHP框架 Yii是一个高性能的,适用于开发WEB2.0应用的PHP框架. Yii是一个基于组件.用于开发大型 Web 应用的 高性能 P ...