当前位置: 首页> 游戏> 评测 > vue3【实战】语义化首页布局

vue3【实战】语义化首页布局

时间:2025/7/9 20:42:52来源:https://blog.csdn.net/weixin_41192489/article/details/140215515 浏览次数:0次

在这里插入图片描述
技术要点,详见注释

<script setup></script><template><div class="page"><header>页头</header><nav>导航</nav><!-- 主体内容 --><main class="row"><aside>左侧边栏<section>区域内容</section></aside><article><h2>文章标题</h2><p>文章段落一</p><p>文章段落二:文章段落二的内容………………文章段落二的内容………………文章段落二的内容………………文章段落二的内容………………文章段落二的内容………………文章段落二的内容………………文章段落二的内容………………</p></article><aside>右侧边栏</aside></main><footer>页脚</footer></div>
</template><style lang="scss" scoped>
.page {/* 绝对定位撑满全屏(避开的浏览器默认样式 html 和 body 存在 margin 和 pandding 的影响)*/position: absolute;top: 0;bottom: 0;left: 0;right: 0;/*  对页面内的元素使用flex布局*/display: flex;/*  垂直方向使用flex布局*/flex-direction: column;/*  最小宽度为左右侧栏的宽度+文章的最小宽度*/min-width: 600px;
}header {background-color: goldenrod;text-align: center;padding: 10px;
}nav {background-color: red;text-align: center;padding: 10px;
}
main {display: flex;/*  主体内容-垂直方向撑满*/flex-grow: 1;background-color: yellow;padding: 10px;
}
aside {background-color: green;width: 200px;padding: 10px;text-align: center;section {background-color: blue;height: 100px;text-align: center;padding: 10px;margin-top: 10px;}
}
article {background-color: blueviolet;padding: 10px;/*  文章-水平方向撑满*/flex-grow: 1;/*  flex-grow: 1;时,需设置 width,其值的效果为最小宽度(否则随文字内容的增加,会挤压左右两侧)*/width: 100px;h2 {text-align: center;}
}footer {background-color: gray;text-align: center;padding: 10px;
}
</style>
关键字:vue3【实战】语义化首页布局

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: