[JS 最简单简洁的插件] 浮动提示 (支持显示Html和手动关闭)
2013-08-10 19:01
651 查看
<!doctype html> <html> <head> <meta charset='utf-8'> <title></title> <style> body{ font-size:18px; } </style> <script src='http://code.jquery.com/jquery.js'></script> </head> <body> <script> $(function(){ $('.mxx_layer').each(function(index,domEle){ var _this = $(domEle); // 设置css $(_this).css({ 'position':'relative', 'display':'inline-block' }); $(_this).find('.mxx_sub').css({ 'position':'absolute', 'display':'none', 'background':'#fff', 'border':'3px solid #fff', 'box-shadow':'1px 1px 2px 2px #999', 'border-radius':'4px', 'padding':'4px 8px', 'color':'#666', 'font-size':'12px', 'line-height':'20px', 'z-index':'9999' }); $(_this).find('.mxx_close').css({ 'position':'absolute', 'bottom':'-9px', 'right':'-2px', 'cursor':'pointer', 'display':'none' }); // 显示方向 var width = $(_this).find('.mxx_sub').width(); var height = $(_this).find('.mxx_sub').height(); var point_1 = 'right',point_2 = 'bottom'; // 默认在右上位置显示 if( $(_this).offset().left < width ){ point_1 = 'left'; } if( $(_this).offset().top < height ){ point_2 = 'top'; } $(_this).find('.mxx_sub').css( point_1, '0' ); $(_this).find('.mxx_sub').css( point_2, $(_this).css('font-size') ); // 绑定事件 var close = 1; if($(_this).attr('data-close') == 'no') close = 0; $(_this).mouseover(function(){ $(_this).find('.mxx_sub').show(); }); if(close){ $(_this).mouseout(function(){ $(_this).find('.mxx_sub').hide(); }); }else{ $(_this).find('.mxx_close').css('display','block'); $(_this).find('.mxx_close').click(function(){ $(_this).find('.mxx_sub').hide(); }); } }); }); </script> 我是 <div class='mxx_layer'>中国<img src='https://cdn3.iconfinder.com/data/icons/fugue/icon/question-frame.png' /> <div class='mxx_sub'> <span class='mxx_close'><img src='https://cdn1.iconfinder.com/data/icons/customicondesign-mini-lightcolour-png/16/Close.png' /></span> <div style='width:300px'> 少林寺投资20亿建足球学校 少林寺投资20亿建足球学校 少林寺投资20亿建足球学校 少林寺投资20亿建足球学校 少林寺投资20亿建足球学校 少林寺投资20亿建足球学校 <!--这里写上自己的内容--></div> </div> </div> 人 <p>hello</p> <p>hello</p> <p>hello</p> <p>hello</p> <p>hello</p> <p>hello</p> <p>hello</p> <p>hello</p> <p>hello</p> <p>hello</p> <p>hello</p> <p>hello</p> <p>hello</p> <p style='display:inline-block;width:400px;'>hello</p> 我是 <div class='mxx_layer' data-close='no'>中国<img src='https://cdn3.iconfinder.com/data/icons/fugue/icon/question-frame.png' /> <div class='mxx_sub'> <span class='mxx_close'><img src='https://cdn1.iconfinder.com/data/icons/customicondesign-mini-lightcolour-png/16/Close.png' /></span> <div style='width:300px'> 少林寺投资20亿建足球学校 少林寺投资20亿建足球学校 少林寺投资20亿建足球学校 少林寺投资20亿建足球学校 少林寺投资20亿建足球学校 少林寺投资20亿建足球学校 <!--这里写上自己的内容--></div> </div> </div> 人 </body> </html>
相关文章推荐
- [JS 最简单简洁的插件] 浮动提示 (title增强型)
- HTML 最简单的tips 怎么支持指定DIV显示提示信息
- 浮动居中js广告插件,支持详细的自定义:最大化播放时长,二次最大化间隔,不显示的url等
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示。
- 在jsp页面下, 让eclipse完全支持HTML/JS/CSS智能提示
- Zend Studio上安装使用Aptana插件(html,css,js代码提示功能)
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示。
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示
- hta+html+js+mediaplay写的支持lrc显示的歌曲播放器
- textarea 标签中placeholder提示信息手动换行(jQuery水印插件watermark.js )
- Jquery的validate,清除form方法,显示密插件,正则特殊字符处理,js的call用法,ajax,h5支持情况,elclipse tomcate去掉项目名,js 的原型
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示。
- Sublime Text 插件之HTML-CSS-JS Prettify—格式化HTML CSS JS与显示函数列表
- myeclipse 8.5 安装aptana插件 提示jQuery、js、css、html
- [JS 最简单简洁的插件] 表格排序
- 在jsp页面下, 让eclipse完全支持HTML/JS/CSS智能提示
- JS直接关闭窗口不提示(支持IE6、IE7)
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示
- Eclipse支持HTML&JS&ExtJS&jQuery代码智能提示