【发布时间】:2018-11-24 02:01:58
【问题描述】:
当我上传不同的像素时,它不显示确切的圆形。它变成椭圆形。但是当我上传方形图片时,它的确切圆形
<div class="profile_pic">
<?php
$model = SimUser::find()->where(['user_id' => Yii::$app->user->identity->user_id])->one();
if ($model->user_profile_image != null) { ?>
<img src="<?= Files::getFilePath($model->user_profile_image, true); ?>" class ="img-circle profile_img img-responsie " />
<?php } else { ?>
<?= Html::img(\Yii::$app->request->BaseUrl . '/web/images/user.png', ['class' => 'img-circle profile_img', 'alt' => '...']); ?>
<?php } ?>
</div>
如果图像的像素也不同,我如何将图像制作成圆形
【问题讨论】:
-
-
我知道实现这一点的唯一可靠方法是不使用图像标签,而是使用 div,在该 div 上设置宽度、高度和边框半径以使其成为圆形,然后添加图像作为居中的背景图像。这样你就可以保持圆形。
-
.profile_pic { width: 100px; height: 100px; border-radius: 50%; overflow: hidden; }