Center Text block vertically according to the size of the div beside

1

My partners, I'm losing my hair with this problem I'm facing.

I have some pages made with bootsptrap, in which each container has a row and has two columns (each with the following classes: col-xs-12 col-sm-12 col-md-6 col- lg-6), in this the lines are alternating between text / image and image / text where the Height value used as a reference is that of the image (usually it is bigger than the text blocks), in that I get the value of the image, I get the height of the text block, I subtract and divide the value by 2 to reach the margin-top so only to be able to vertically center the text blocks according to the center of the image.

I made some cats and I do not know if the logic would be this: link

The thing itself works, the problem however is that the code only works when we refresh the page when we load it again. It does not work when we open it for the first time and this is the problem as it should center as soon as the page loads.

Could someone tell me what my mistake is or if possible a way to solve it? Thanks!

    
asked by anonymous 31.03.2015 / 02:57

1 answer

2

Try adding this to the end:

$(document).ready(function() {
    WszW = $(window).width();
    gTCP(WszW);
});

If your JS is before the images or before the window size is resolved, this will ensure that it refreshes the width at the end of the page load, and that it executes the function again, with the defined width. >     

31.03.2015 / 03:15