Hey guys i may be posting this in the wrong forum but its php related but i guess more css.
i have thumbnails that i need to center vertically. i manage to get centered in a way but then i ran into a bug since the photos i was using had a 3:2 ratio and once i loaded a 4:3 ratio photo it was not centered anymore
the original code looked like this:
list($width, $height) = getimagesize($imagename) ;
if ( $width > $height ) {
$top=round(((80-$height)/2),0);
echo ("<div id='emailphoto'><a href='profile.php?UID=$finfo[userid]&UN=$finfo[username]'><img class='landscape' src='$imagename'/></a></div>");
} else { echo ("<div id='emailphoto'><a href='profile.php?UID=$finfo[userid]&UN=$finfo[username]'><img class='portrait' src='$imagename'/></a></div>"); }
the style elements looked like this in the style sheet.
#emailphoto img{
display:block;
margin-left:auto;
margin-right:auto;
}
#emailphoto img.landscape {
margin-top:12px;
width:80px;
}
#emailphoto img.portrait {
margin-top:0px;
height:80px;
}
is there anyway i can make the margin-top in the style sheet change dynamicly using the $top value?
i've tried including the style in the <img> tag but havent had any success?