如何将jQuery图片实现垂直水平居中的长尾?
- 内容介绍
- 文章标签
- 相关推荐
本文共计128个文字,预计阅读时间需要1分钟。
jQuery实现图片垂直水平居中:
javascriptjQuery(function($) { $.fn.extend({ imgHook: function(opt) { opt=jQuery.extend({className: img-hook}, opt); var th=$(this); if (th.length > 0) { if (th[0].tagName==='IMG') { th.wrap(''); th.before(''); } } } });});
jquery图片垂直水平居中;(function ($) { $.fn.extend({ imgHook: function (opt) { opt = jQuery.extend({className: "img-hook"}, opt); var th = $(this); if (th.length > 0) { if (th[0].tagName == 'IMG') { th.wrap(''); th.before('') } else { th.addClass(opt.className); th.prepend('') } } } }); })(jQuery); //引用 $(".img").imgHook(); /* 主要样式 .img-hook { text-align: center; font-size: 0; overflow: hidden } .img-hook img { vertical-align: middle; max-width: 100%; max-height: 100% } .img-hook .hook { display: inline-block; width: 0; height: 100%; overflow: hidden; font-size: 0; line-height: 0; vertical-align: middle } */ /* */
本文共计128个文字,预计阅读时间需要1分钟。
jQuery实现图片垂直水平居中:
javascriptjQuery(function($) { $.fn.extend({ imgHook: function(opt) { opt=jQuery.extend({className: img-hook}, opt); var th=$(this); if (th.length > 0) { if (th[0].tagName==='IMG') { th.wrap(''); th.before(''); } } } });});
jquery图片垂直水平居中;(function ($) { $.fn.extend({ imgHook: function (opt) { opt = jQuery.extend({className: "img-hook"}, opt); var th = $(this); if (th.length > 0) { if (th[0].tagName == 'IMG') { th.wrap(''); th.before('') } else { th.addClass(opt.className); th.prepend('') } } } }); })(jQuery); //引用 $(".img").imgHook(); /* 主要样式 .img-hook { text-align: center; font-size: 0; overflow: hidden } .img-hook img { vertical-align: middle; max-width: 100%; max-height: 100% } .img-hook .hook { display: inline-block; width: 0; height: 100%; overflow: hidden; font-size: 0; line-height: 0; vertical-align: middle } */ /* */

