关于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>
相关推荐
yuanyxh4 小时前
Mac 软件推荐
前端·javascript·程序员
万少4 小时前
AtomCode开发微信小程序《谁去呀》 全流程
前端·javascript·后端
某人辛木4 小时前
Web自动化测试
前端·python·pycharm·pytest
Kagol5 小时前
Superpowers GSD gstack AgentSkills深度测评
前端·人工智能
excel6 小时前
JavaScript 字符串与模板字面量:从表象到本质理解
前端
京东云开发者6 小时前
当AI成为导演-如何用AI创作动漫短剧
前端
李白的天不白7 小时前
使用 SmartAdmin 进行前后端开发
java·前端
乘风gg7 小时前
🤡PUA AI Coding 工具 的 10 条终极语录
前端·ai编程·claude
学Linux的语莫7 小时前
Vue 3 入门教程
前端·javascript·vue.js
怕浪猫7 小时前
第一章、Chrome DevTools Protocol (CDP) 详解
前端·javascript·chrome