gpt4 book ai didi

javascript - 如何像google一样在圆圈中显示不同分辨率的动态图片?

转载 作者:行者123 更新时间:2023-12-03 10:06:54 25 4
gpt4 key购买 nike

如何像Google一样在圆圈中显示不同分辨率的动态图片?我尝试使用 bootstrap class class="img-circle"但它适用于某些分辨率为 304*236 的图像。但如果图像的分辨率不同,它将无法正常显示(它将呈椭圆形或带有弯曲边缘的正方形)。

我的场景1. 用户从本地系统中选择他的个人资料图片。2. 将图像保存到服务器中3.以圆圈显示头像

  1. 谁能告诉我如何在圆圈中显示不同分辨率的图像?
  2. 或者我应该强制用户仅选择特定尺寸的图像作为个人资料图片?
  3. 或者我可以编写一些代码来裁剪图像并保存吗?
  4. 如何允许用户裁剪图像以及如何将其保存在服务器中。

我的项目正在使用 ASP.net MVC。

最佳答案

尝试使用此代码:

HTML

<div class="profile-box">
<div class="profile-picture" style="background: #fff url('URL-IMAGE') no-repeat 50% 50%; background-size: cover;">
<a href="#" class="btn active" style="width:100%;height:100%;">&nbsp;</a>
</div>
</div>

CSS

.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border: 1px solid transparent;
}
.profile-box {
box-shadow: none;
background: transparent;
padding-top: 5px;
position: relative;
overflow: hidden;
}
.profile-box .profile-picture {
position: relative;
top: 0;
left: 0;
margin-left: 0;
border: 5px solid #fff;
border-radius: 100%;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
width: 150px;
height: 150px;
overflow: hidden;
background: #fff;
text-align: center;
margin: 0 auto;
}

关于javascript - 如何像google一样在圆圈中显示不同分辨率的动态图片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30318502/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com