다음 jQuery 플러그인은 결과를 알려줍니다.
(function($) {
$.fn.isOverflowWidth = function() {
return this.each(function() {
var el = $(this);
if (el.css("overflow") == "hidden") {
var text = el.html();
var t = $(this.cloneNode(true)).hide().css('position', 'absolute').css('overflow', 'visible').width('auto').height(el.height());
el.after(t);
function width() {
return t.width() > el.width();
};
alert(width());
}
});
};
})(jQuery);
이 높이에서 오버 플로우를 확인하려면
CSS
#tempDiv{
height:10px;
overflow:hidden;
}
가 폭의 오버 플로우를 확인하려면,
(function($) {
$.fn.isOverflowHeight = function() {
return this.each(function() {
var el = $(this);
if (el.css("overflow") == "hidden") {
var text = el.html();
var t = $(this.cloneNode(true)).hide().css('position', 'absolute').css('overflow', 'visible').height('auto').width(el.width());
el.after(t);
function height() {
return t.height() > el.height();
};
alert(height());
}
});
};
})(jQuery);
http://jsfiddle.net/C3hTV/
정확하게 "감지"한다는 것은 무엇을 의미합니까? 반응에서 무엇을하고 싶습니까? 스크롤바를 보여 주시겠습니까? –
텍스트가 넘칠 경우 마우스를 가리키면 div 크기를 조정하려고하지만 이미 정렬 했으므로 질문의 일부가 아닙니다. –
위대한 답변과 비슷한 오래된 질문 : https://stackoverflow.com/a/143889/573057 – earcam