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>
相关推荐
大怪v1 小时前
AI抢饭?前端佬:我要验牌!
前端·人工智能·程序员
新酱爱学习1 小时前
字节外包一年,我的技术成长之路
前端·程序员·年终总结
小兵张健1 小时前
开源 playwright-pool 会话池来了
前端·javascript·github
IT_陈寒4 小时前
Python开发者必知的5大性能陷阱:90%的人都踩过的坑!
前端·人工智能·后端
codingWhat4 小时前
介绍一个手势识别库——AlloyFinger
前端·javascript·vue.js
代码老中医4 小时前
2026年CSS彻底疯了:这6个新特性让我删掉了三分之一JS代码
前端
不会敲代码14 小时前
Zustand:轻量级状态管理,从入门到实践
前端·typescript
踩着两条虫4 小时前
VTJ.PRO 双向代码转换原理揭秘
前端·vue.js·人工智能
扉川川4 小时前
OpenClaw 架构解析:一个生产级 AI Agent 是如何设计的
前端·人工智能
远山枫谷5 小时前
一文理清页面/组件通信与 Store 全局状态管理
前端·微信小程序