Javascript-форум (https://javascript.ru/forum/)
-   jQuery (https://javascript.ru/forum/jquery/)
-   -   Автоматическое высота (https://javascript.ru/forum/jquery/21377-avtomaticheskoe-vysota.html)

minotavr_x86 07.09.2011 08:17

Автоматическое высота
 
$.fn.tagName = function() { 
    return this.get(0).tagName.toLowerCase(); 
} 
$.fn.autoHeight = function(){
	var els = this;
	var wh = $(window).height();
	$('#debug_info').html('1');
	els.each(function(){			
		  el = this;
		  i = this;			
		  var a = 0;				
		  do{
		      $(i).prevAll(':visible').add($(i).nextAll(':visible')).not('#alertmod').each(function(){
			      a = a + $(this).outerHeight(true);							
		      });				
		      i = $(i).parent();				
		}while ($(i).tagName() != 'body');								
		$(el).height( wh - a - ($(el).outerHeight(true) - $(el).height()));			
	});		
};

Код работает, но внутри родительского элемента бывают отступы, как например в table это border-spacing, как их учесть?


Часовой пояс GMT +3, время: 23:00.