-1

I have an image being pulled out of a forum (avatars), but every time i grab them, they are not fitting my div, no matter what i do, i'm wondering how can i fit that image inside my div?

Here's the line i'm talking about:

<div id="image">'.$ipbwi->member->photo($friend['friends_friend_id']).'</div>

And here's a whole foreach:

<?php
$friends = $ipbwi->member->friendsList(false,true);
foreach($friends as $friend){
echo '
<div class="friend">
<div id="image">'.$ipbwi->member->photo($friend['friends_friend_id']).'</div>
<div class="username">'.$ipbwi->member->id2displayname($friend['friends_friend_id']).'</div>
</div>
';
}
?>

I'm using ipbwi to pull data from ipb forum and i would like to scale all the images to (example) 40x40px.

Edit:

here's the css i'm using for img on div: #friend #image img{width: 40px; height: 40px;}

Thanks in advance!

4

3 回答 3

1

尝试添加样式规则

.friend img { max-width:100px; max-height:100px }
于 2013-05-13T21:33:53.397 回答
0

我过去曾这样做过。

.img-resize {
  width: 200px;
  height : auto;
}

.img-resize {
  width: auto;
  height : 300px;
}

创建一个 CSS 类img-resize并给它你想要的宽度和高度。这将保持纵横比。像这样使用:<img src="http://example.com/12.jpg" class="img-resize" /> 然后你可以scr用数据库中的值替换。

于 2013-05-13T21:33:29.330 回答
0

使用此 CSS 调整图像大小:

img {
  max-width: 40px;
  max-height: 40px;
}

另外,请记住,这将适用img于您页面上的每个标签,因此更具体地说,您可以执行以下操作:

.friend img {
  max-width: 40px;
  max-height: 40px;
}

这只会重新调整带有“朋友”div标签内的图像大小class

于 2013-05-13T21:33:37.323 回答