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>
相关推荐
瞌睡不醒几秒前
在行情面板中加入 K 线:一次结构升级的实现过程
前端
Flywith2415 分钟前
【2025 年终总结】北漂五年,而立,婚礼,折叠车
android·前端·程序员
Aliex_git24 分钟前
gzip 压缩实践笔记
前端·网络·笔记·学习
木昆子24 分钟前
实战A2UI:从JSON到像素——深入Lit渲染引擎
前端·人工智能
an3174228 分钟前
React 页面加载埋点的正确姿势:useEffect 与 document.readyState 完美配合
前端·javascript·react.js
1024小神1 小时前
vue3项目配置了子路由后刷新页面回到首页解决办法
前端·javascript·vue.js
_Rookie._1 小时前
npm run 的原理
前端·npm·node.js
木斯佳1 小时前
前端八股文面经大全:2026-01-13MiniMax前端实习二面面经深度解析
前端·状态模式
远离UE41 小时前
Blender模型正常导入UE5 FBX 轴向匹配
前端
谭光志1 小时前
OpenClaw 安装与运行教程
前端·后端·ai编程