图标未在 html Bootstrap 中垂直居中对齐 5

Icon not aligning vertically center in html Bootstrap 5

我目前是 Css 的新手 google 图标没有垂直居中对齐,从底部开始有一些填充,您可以在附件中看到...文本居中对齐

.g-icon{
background-image: url("../../assets/imgs/googles.png");
background-repeat: no-repeat;
height: 28px;
width:28px;}

对于html

 <div class="text-center pl-3 pt-3 pb-3 shadow bg-white rounded reg-head">
   <i class="g-icon  d-flex align-items-center"></i>
     <div class="reg">
      <label class=" mx-0 my-0"> Register with Google</label>
     </div>
  </div>

这是我的屏幕截图 Output for css code

我给你两种可能:

  1. 在 css 中,您可以使用 属性“浮动”来粘贴文本和 google 图标。 参见:https://developer.mozilla.org/fr/docs/Web/CSS/float

  2. 您可以将 google 图标标签直接放在与文本相同的标签中。例如:<p><img src="link/to/google/img">Google text<p>

提供 Css 给 div..

display:flex;
align-items-center;
justify-content:flex-start;