当前位置: 首页 > article >正文

【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:外边距 (可设置具体像素值或百分比)
在这里插入图片描述


http://www.kler.cn/a/555520.html

相关文章:

  • LLM基础概念(RAG、微调流程、Prompt)
  • 利用ollama本地部署deepseek
  • AI大模型零基础学习(7):边缘智能与物联网——让AI走出云端
  • Go Web 开发基础:从入门到实战
  • 无人机避障——感知篇(采用Mid360复现Fast-lio)
  • 第四篇:开源生态与蒸馏模型的价值
  • leetcode day19 844+977
  • 【Java八股文】08-计算机网络面试篇
  • Unity3D协程的优化方案
  • 通过C语言实现“数据结构”课程中的链表,数据,数,图
  • C语言.h头文件的写法
  • 啥是CTF?新手如何入门CTF?网络安全零基础入门到精通实战教程!
  • vue 父组件和子组件中v-model和props的使用和区别
  • [AI相关]生成视频-第一个项目,20k星开源MoneyPrinterTurbo
  • PostgreSQL 与 MySQL 有哪些区别
  • C++中间件DDS介绍
  • Java高级研究.练习
  • UGUI RectTransform的SizeDelta属性
  • docker安装ros2 并在windows中显示docker内ubuntu系统窗口并且vscode编程
  • IM 即时通讯系统-02-聊一聊 IM 要如何进行架构设计?