欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 养生 > 【Vue】前端记录点

【Vue】前端记录点

2025/2/24 14:42:16 来源:https://blog.csdn.net/evelol7/article/details/145758520  浏览:    关键词:【Vue】前端记录点

居中的几种方式

1.行内元素居中,想要让行内元素(如 <span> 或 <a>)在其父容器中居中

<template><div class="center-text"><span>居中的文本</span></div>
</template><style>
.center-text {text-align: center;
}
</style>

2.块级元素居中

使用flex布局

<template><div class="flex-center"><p>居中的文本</p></div>
</template><style>
.flex-center {display: flex;justify-content: center; /* 水平居中 */align-items: center; /* 垂直居中 */height: 100px; /* 示例高度 */
}
</style>

使用grid布局

<template><div class="grid-center"><p>居中的文本</p></div>
</template><style>
.grid-center {display: grid;place-items: center; /* 同时水平垂直居中 */height: 100px; /* 示例高度 */
}
</style>

盒子模型

width:内容的宽度
height:内容的高度
padding:内边距
border:边框
margin:外边距 (可设置具体像素值或百分比)
在这里插入图片描述

版权声明:

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

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

热搜词