2.3.父元素中的子元素设置居中效果

2024-11-21  本文已影响0人  ChaosHeart

1.父元素中的子元素设置居中效果

display: flex;
align-items: center; /* 上下居中 */
justify-content: center; /* 左右居中 */

例子:

.left {
  display: flex;
  align-items: center;
  width: 50%;
  height: 100%;
  background: white;
}

.left-logo {
  width: 38px;
  height: 38px;
  background: url(assets/logo.png) 0 0 no-repeat;
  background-size: cover;
}

.left-title {
  font-size: 24px;
  font-weight: 600;
  color: #1a66ff;
  font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}
上一篇 下一篇

猜你喜欢

热点阅读