检查内容是否溢出 [英] Check to see if content overflows
本文介绍了检查内容是否溢出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要知道我的内容何时溢出了我的div。如果是这样,我会在一个链接中打开包含所有内容的新窗口。
I need to know when my content overflows my div. If it does, I'll be placing in a link to open the page in a new window with all of the content.
干杯,
DalexL
推荐答案
这是一个适合文本宽度和高度的jquery插件:
this a jquery plugin for fit text to width and height:
(function($) {
$.fn.fitText = function(options) {
options = $.extend({
width: 0,
height: 0
}, options);
$(this).each(function() {
var elem = $(this);
if (options.height > 0) {
while (elem.height() > options.height) {
elem.text(elem.text().substring(0, (elem.text().length - 4)) + 'YourLink');
}
}
if (options.width > 0) {
while (elem.width() > options.width) {
elem.text(elem.text().substring(0, (elem.text().length - 4)) + 'YourLink');
}
}
});
}
})(jQuery);
这篇关于检查内容是否溢出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文