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>
相关推荐
颜进强4 小时前
LangChain 从入门到实践:用最小案例理解 RAG 的 5 个核心抽象
前端·后端·ai编程
颜进强4 小时前
MCP 从入门到实践:用 TypeScript 实现第一个 MCP Server
前端·后端·ai编程
朕的剑还未配妥5 小时前
CSS 实现渐变毛玻璃:从 backdrop-filter 到多层 mask
前端·css
程序员黑豆5 小时前
鸿蒙开发实战:使用 List 组件构建新闻列表
前端·华为·harmonyos
xiaobaoyu5 小时前
谈谈你对iframe的了解
前端
GISer_Jing5 小时前
前端转全栈须知后端知识
前端·后端·ai·前端框架
爱勇宝5 小时前
我做了一个排版器,也踩了一遍富文本复制的坑
前端·后端·微信
铁皮饭盒6 小时前
面试官:如何用 Bun + JS 实现安全的文件 MCP 工具集
前端·javascript·后端
探索前端6 小时前
Cesium图层加载及影像服务添加
前端·cesium
阿懂在掘金6 小时前
Vue 弹窗新范式——代码减少、复用翻倍与 AI 时代的前端基建
前端·设计模式·前端框架