关于CSS Grid布局

关于CSS Grid布局

实际效果参考

参考代码

vue 复制代码
<template>
	<view class="baseInfo">
		<up-image class="cover" height="160rpx" width="120rpx" :src="bookInfo.cover">
			<template #error>
				<view style="font-size: 24rpx;">加载失败</view>
			</template>
		</up-image>
		<up-text class="title" :text="bookInfo.title" :lines="1" :size="15" bold />
		<up-text class="desc" type="info" :size="14" :text="bookInfo.desc" wordWrap="anywhere" :lines="2" />
		<view class="tags">
			<up-tag class="tag" v-for="tag in bookInfo.tags" :text="tag" size="mini" plain plainFill />
		</view>
	</view>
</template>

<script setup lang="ts">
	import { reactive, ref } from 'vue'
	const props = defineProps({
		bookInfo: {
			type: Object,
			default: '',
		},
	});
</script>

<style scoped lang="scss">
	.baseInfo {
		margin: 2%;
		padding: 2%;
		display: grid;
		grid-template-columns: repeat(1, 120rpx) repeat(5, 1fr);
		/* 第一列固定宽度,其余列自适应 */
		grid-template-rows: repeat(3, auto);
		grid-template-areas:
			"cover title title title title title"
			"cover tags tags tags tags tags"
			"cover desc desc desc desc desc";
		grid-gap: 2%;
		border-radius: 8rpx;
		background-color: #FFF;

		* {
			max-width: 86%;
		}

		.cover {
			grid-area: cover;
		}

		.title {
			grid-area: title;
		}

		.desc {
			color: #080808;
			grid-area: desc;
		}

		.tags {
			grid-area: tags;

			.tag {
				padding-right: 2%;
			}
		}

	}
</style>
相关推荐
派小心.1 小时前
A/B测试工具免费版够用吗?
前端·数据分析
前端snow1 小时前
ai agent --- redis 缓存
前端
duanshu_2 小时前
官网表单与下载异常怎么排查?五个环节定位故障
前端·自动化·flyweight
Zhou1411362 小时前
SpringBoot_03_Web开发
前端·spring boot·python
辻弋2012 小时前
【无标题】
大数据·服务器·前端·搜索引擎·开源软件
FluxArt3 小时前
GPT Image 2.5 中文提示词教程:Flux Art 可复用模板
前端·gpt·算法
搬砖的小码农_Sky4 小时前
AI Agent:Windows上Node.js安装后 npm -v报错
前端·npm·node.js·人机交互
计算机魔术师4 小时前
半年翻倍!OpenAI再融300亿,估值冲到1.4万亿
前端
研☆香5 小时前
jQuery + Swiper.js 实现动态渲染轮播图
前端·javascript·jquery
子兮曰5 小时前
Node.js 50个优势场景盘点:一个人单干,为啥我多数时候只用它
前端·后端