E
E
eellazy2015-08-23 15:46:40
PHP
eellazy, 2015-08-23 15:46:40

How to add width to elements, if necessary?

Hello everyone, there is an event that, if necessary, adds the width of the block. Made for the purpose of visualization of elements. They all look the same.

$.fn.equivalent = function (){
        var $blocks = $(this), 
            maxH    = $blocks.eq(0).height();
        $blocks.each(function(){
            maxH = ( $(this).height() > maxH ) ? $(this).height() : maxH;
        });

      $blocks.height(maxH); //устанавливаем найденное максимальное значение высоты для каждого блока jQuery выборки
    }
    $('.listing-card.col-md-2 .listing-attr.radius_app').equivalent(); //применяем нашу функцию в элементам jQuery выборки - $()
    $('.listing-card.col-sm-6.col-md-4 .figure').equivalent(); //применяем нашу функцию в элементам jQuery выборки - $()
    
    
    $(window).resize(function(){
      $('.listing-card.col-md-2 .listing-attr.radius_app').css('height','auto').equivalent();
    });
    $(window).load(function () {
      $('.listing-card-list').animate({
        'opacity':1
      },300);
    });


But there's a problem. When resizing the window, everything is shown as it should. But if you simply refresh the page. The blocks are cut. eaa869f3d87f4c4b9d3c3851a2342343.png

Or what other alternatives are there to adding height to a block if needed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2019-02-27
@Dizzy221

add exit after uploading the file.
if the page has any output before, take advantage of output buffering.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question