mardi 4 août 2015

Horizontally aligning textbox with label when the two are in different divs

I am trying to align a series of text boxes with their corresponding labels. Since they are in two different divs, I am unable to use the inherit keyword. I have tried using the javascript/jquery code below to align the pairs of elements, but $(tb).css('left') just returns auto. Does anyone know how to achieve this alignment using html, css, and/or javascript/jquery and without using a table?

$(function() {
    $('#infoLabels label').each(function(idx,lbl) {
        var tb = $('#' + lbl.htmlFor);

        ($(tb).width() > $(this).width()) ? $(this).width($(tb).width()) : $(tb).width($(this).width());
        $(this).css('left',$(tb).css('left'));                
    });
});

http://ift.tt/1JK3Fdj

Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire