如何保持图像缩略图的纵横比,使其看起来不会被挤压?如何保持图像缩略图的纵横比
protected function DisplayPhoto($Sender) {
$body = $Sender->EventArguments['Discussion']->Body;
preg_match('#\<img(.+?)src=(.+?)\>#s', $body, $matches);
if(isset($matches[2])){
$image = "src=" . $matches[2];
echo '<img class="ProfilePhotoSmall"' . $image . '>';
}else{
//do what you want
}
}
这是CSS。
ul.Discussions li img {
height: 60px;
width: 110px;
padding: 0 6px 0 4px;
float: right;
position: relative;
}
.Discussion.ItemContent {
padding-right: 0px;
padding-bottom: 10px;
display: inline;
}
CSS的样子是什么?.ProfilePhotoSmall?除了CSS内部,我找不到任何改变图像大小的方法? – BenM
提供了CSS。谢谢。 – user3040048