uniapp中如何通过css实现圆形头像样式

核心代码:

css 复制代码
	#top-card .top image{
		width: 60rpx;
		height: 60rpx;
		border-radius: 30rpx;
	}

关键知识点:宽高相同,圆角值为宽高值的一半。

修改之前的效果:

修改之后的效果:

完整代码:

html 复制代码
<script setup>
	import {
		onMounted,
		ref
	} from 'vue';
	const src = "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg"
	const data = ref([])

	onMounted(() => {
		uni.request({
			method: "GET",
			url: 'http://192.168.234.138:8889/zdppy_amfile',
			dataType: "json",
			success: (res) => {
				console.log(res.data);
				data.value = res.data.data.results
			}
		})
	})
</script>

<template>
	<view class="content">
		<view id="top-card">
			<view class="top">
				<image src="../../static/boy1.png"></image>
				<view>测试名字</view>
			</view>
			<view class="bottom">
				<button>查找照片</button>
				<button>亲友团</button>
			</view>
		</view>


		<view class="img-list">
			<image v-for="(v,k) in data" :key="k" :src="`http://192.168.234.138:8889/download/${v.path}`"
				mode="aspectFill" />
		</view>
	</view>
</template>



<style scoped>
	.content {
		margin: auto;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	/* 顶部卡片开始 */
	#top-card {
		margin-bottom: 10rpx;
		background-color: aliceblue;
	}

	#top-card .top {
		display: flex;
	}
	
#top-card .top image{
		width: 60rpx;
		height: 60rpx;
		border-radius: 30rpx;
	}

	#top-card .bottom {
		display: flex;
	}

	/* 顶部卡片结束 */

	.img-list {
		padding: 10rpx;
		column-count: 2;
		column-gap: 10rpx;
	}
</style>
相关推荐
再学一点就睡2 小时前
前端网络实战手册:15个高频工作场景全解析
前端·网络协议
C_心欲无痕3 小时前
有限状态机在前端中的应用
前端·状态模式
C_心欲无痕3 小时前
前端基于 IntersectionObserver 更流畅的懒加载实现
前端
candyTong3 小时前
深入解析:AI 智能体(Agent)是如何解决问题的?
前端·agent·ai编程
柳杉3 小时前
建议收藏 | 2026年AI工具封神榜:从Sora到混元3D,生产力彻底爆发
前端·人工智能·后端
weixin_462446233 小时前
使用 Puppeteer 设置 Cookies 并实现自动化分页操作:前端实战教程
运维·前端·自动化
CheungChunChiu3 小时前
Linux 内核动态打印机制详解
android·linux·服务器·前端·ubuntu
GIS之路4 小时前
GDAL 创建矢量图层的两种方式
前端
小目标一个亿5 小时前
Windows平台Nginx配置web账号密码验证
linux·前端·nginx
rocky1915 小时前
网页版时钟
前端·javascript·html