简体   繁体   English

将 ion-icon 放在 ion-avatar 右下边框上

[英]Place ion-icon on ion-avatar bottom-right border

Got this avatar design displaying profile pic, name and surname, and an icon to change the profile pic.得到这个头像设计,显示个人资料图片、姓名和姓氏,以及一个用于更改个人资料图片的图标。

头像图片

Right now the icon is too low, I'd like to have it higher near the image, possibly on the border but any closer will be alright.现在图标太低了,我想让它在图像附近更高,可能在边框上,但再靠近一点就可以了。 Trying to get as close as possible to this design:试图尽可能接近这个设计:

设计

Here's my code so far:到目前为止,这是我的代码:

<ion-avatar class="profile-pic-container">
    <ion-img src="../../../assets/images/profile-pic.jpg"></ion-img>
    <ion-icon id="camera-icon" name="camera"></ion-icon>
</ion-avatar>
.profile-pic-container {
    height: 100px;
    width: 100px;
}

ion-avatar {
    // make the icon stay on the right
    text-align: right;
}

#camera-icon {
    font-size: 24px;
}

I tried putting the ion-icon inside the ion-img tag but it disappears, tried playing with the icon's align and position but I'm either thinking about it the wrong way or not good enough with css since I can only manage to make it stay on the left.我尝试将 ion-icon 放在 ion-img 标签内,但它消失了,尝试使用图标的对齐和位置,但我要么以错误的方式思考它,要么用 css 不够好,因为我只能设法做到留在左边。

Set the container to position: relative , and then absolute ly position the camera icon.将容器设置为position: relative ,然后absolute定位相机图标。

.profile-pic-container {
  position: relative;
  height: 100px;
  width: 100px;
}

ion-avatar {
  text-align: right;
}

#camera-icon {
  font-size: 24px;
  position: absolute;
  bottom: 12px; // tweak this
  right: 12px; // tweak this
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM