0

i am showing content with php and mysql and there is a field for a photo which has a % kinda width and i set the height with jquery to have a square and then give the images with bigger width a bigwidth class and the ones with bigger height a bigheight class so i can give them diffrent styles the one with the bigger width gets 100% width and auto height and the one with the bigger height gets height 100% and auto width but with the bigger width images there is a vertical alignment problem for the photos and i cant use display table cell so i though to use padding top with jquery to fix this but since images with bigger width have diffrents ratios there should be diffrent amount of padding for each so i want to select the parent of each bigwidth photo then get its child height then set the needed padding but i dont know how

    <div class="imgpro"><img src="<?php echo("admin/uploads/".$rowpro["propic"]) ?>" class="<?php $size=getimagesize("admin/uploads/".$rowpro["propic"]);
            $wsize=$size[0];$hsize=$size[1];
            if($hsize>$wsize){echo("bigheight");}                                       
    else{echo("bigwidth");}
                                                            ?> "/>
        </div>



        var a=$(".product .imgpro").css("width");

        $(".product .imgpro").css("height",a);

.product .imgpro img.bigheight{height: 100%;width: auto;}
.product .imgpro img.bigwidth{width: 100%;height: auto;}

im trying to select all images parents and give them padding based on the image size in them

  • Welcome to SO, please take a look at how to ask a question: http://stackoverflow.com/help/how-to-ask Please provide some code, what you have tried and where you have failed. Thank you! – AT82 Jan 08 '17 at 08:48
  • 1
    Possible duplicate of [$(this) selector and children?](http://stackoverflow.com/questions/306583/this-selector-and-children) – TIGER Jan 08 '17 at 08:51

0 Answers0