前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >vue css 实现在盒子中居中对齐

vue css 实现在盒子中居中对齐

作者头像
solate
发布2021-03-11 11:37:04
2.8K0
发布2021-03-11 11:37:04
举报
文章被收录于专栏:solate 杂货铺solate 杂货铺

需求

需要在一个盒子内将文字水平垂直居中对齐

实现

代码语言:javascript
复制
<template>
  <div>
    <div class="wrapper">
      <div class="wrapper-content" v-for="item in dataList">
        <div class="child-box">
          <span class="child-font">{{item.id}}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Test',
  data () {
    return {
      dataList: [
        { id: 1, name: 'F1' },
        { id: 2, name: 'F2' },
        { id: 3, name: 'F3' },
        { id: 4, name: 'F4' },
        { id: 5, name: 'F5' },
        { id: 6, name: 'F6' },
        { id: 7, name: 'F6' },
      ]
    }
  },
}
</script>

<style scoped>

.wrapper{
  width: 100%;
  height: auto;
  display: flex;
  justify-content: space-between;
  flex-direction: row;
  flex-wrap: wrap;
}
.wrapper-content{
  width: 33%;
  margin-top: 20px;
}

/*
在盒子中水平垂直居中
*/
.child-box {
  box-shadow: 0 0 30px 2px #918f8f;
  width: 300px;
  height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0 auto;
  text-align: center;
}
.child-font {
  color: #2D71DB;
}

</style>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 需求
  • 实现
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档