Quantcast
Channel: INSIGMA NEWSBLOG » Frontend
Viewing all articles
Browse latest Browse all 2

Adjust height of responsive Bootstrap columns with JQuery

$
0
0

So toll das Gridsystem von Bootstrap auch ist – jeder, der es einsetzt, wird auch mit den unerwünschten Effekten dieses Systemes konfrontiert.
Befinden sich mehrere responsive Columns mit unterschiedlichem hohem Inhalt in einer Row, dann entsteht eine Treppenstruktur, sobald die Seite zusammengeschoben wird:

AdjustColumnsOfBootstrapRows

Mit dem adjustColumnsOfRow() Plugin kann dieses Verhalten übersteuert werden.
Nach erfolgter JQuery-Initialisierung kann das Plugin folgendermaßen aufgerufen werden.

$(document).ready(function ()
{
  // Adjusts height of each column in all bootstrap rows
  $("div.row").adjustColumnsOfRow();
});

Die Höhe der einzelnen Columns wird beim Resizen der Seite automatisch neu berechnet.

Mit Hilfe dieses JQuery Funktionsprototypen kann die Funktion *adjustColumnsOfRow()* als typisches JQuery-Plugin initialisiert werden.

/* ===================================================================== */
/* Adjust height of responsive Bootstrap-Columns automatically           */
/* (C)2014-2015 INSIGMA IT Engineering GmbH; LBr                         */
/* v1.00                                                                 */
/* ===================================================================== */
(function ($)
{
    $.fn.adjustColumnsOfRow = function (options, noAttach)
    {
        /// <summary>Setzen einer einheitlichen Höhe von responsiven Bootstrap-Columns in einer Bootstrap-Row</summary>
        /// <param name="options" type="Array" optional="true">
        ///     Einstellungen
        /// </param>
        /// <param name="noAttach" type="Boolean" optional="true">
        ///     For internal use only!
        /// </param>

        var settings = $.extend({
            columnSelector: "div[class^='col-']"
        }, options);

        $.each(this, function (idx)
        {
            try
            {
                var $cols = $(this).find(settings.columnSelector);

                var h = 0;
                $($cols).each(function ()
                {
                    $(this).css({ "height": "auto" });
                    if ($(this).outerHeight() > h)
                    {
                        h = $(this).outerHeight();
                    }
                    $(this).css({ "height": h });
                });

                $($cols).each(function ()
                {
                    $(this).css({ "height": h });
                });

                if (!noAttach)
                {
                    $(window).on("resize", { rows: this, settings: options }, function (e)
                    {
                        $(e.data.rows).adjustColumnsOfRow(e.data.settings, true);
                    });
                }
            }
            catch (exc)
            {
                alert("adjustColumnsOfRow(): " + exc);
            }
        });
        return this;
    };
}(jQuery));

Viewing all articles
Browse latest Browse all 2

Latest Images

Pangarap Quotes

Pangarap Quotes

Vimeo 10.7.0 by Vimeo.com, Inc.

Vimeo 10.7.0 by Vimeo.com, Inc.

HANGAD

HANGAD

MAKAKAALAM

MAKAKAALAM

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Trending Articles


Imágenes de Robin Hood para colorear


Dino Rey para colorear


Libros para colorear


Mandalas de flores para colorear


Dibujos para colorear de perros


Toro para colorear


People Walk Away Quotes, Inspire Quotes


Long Distance Relationship Tagalog Love Quotes


Tamis Ng tagumpay


RE: Mutton Pies (mely)


Pokemon para colorear


Winx Club para colorear


Girasoles para colorear


Sapos para colorear


Renos para colorear


Dromedario para colorear


Inspirational Tagalog quotes and Motivational English Quotes


Love Quotes Tagalog


Pangarap Quotes


Mga Tala sa “Unang Siglo ng Nobela sa Filipinas” (2009) ni Virgilio S. Almario





Latest Images

Pangarap Quotes

Pangarap Quotes

Vimeo 10.7.0 by Vimeo.com, Inc.

Vimeo 10.7.0 by Vimeo.com, Inc.

HANGAD

HANGAD

MAKAKAALAM

MAKAKAALAM

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC