简体   繁体   English

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

[英]Icon not aligning vertically center in html Bootstrap 5

I am currently new to Css google icon is not getting align center vertticaly giving some padding from bottom you can see in attached file...text is aligned center我目前是 Css 的新手,谷歌图标没有垂直对齐中心,从底部提供一些填充,您可以在附件中看到...文本居中对齐

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

for html适用于 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>

Here is my screen short Output for css code这是我的屏幕短Output 用于 css 代码

I offer you two possibilities:我给你两种可能:

  1. In css you can use the property "float" to stick your text and your google icon.在 css 中,您可以使用属性“float”来粘贴您的文本和您的谷歌图标。 See: https://developer.mozilla.org/fr/docs/Web/CSS/float请参阅: https://developer.mozilla.org/fr/docs/Web/CSS/float

  2. You can place your google icon tag directly in the same tag as your text.您可以将您的谷歌图标标签直接放在与您的文本相同的标签中。 For exemple: <p><img src="link/to/google/img">Google text<p>例如: <p><img src="link/to/google/img">Google text<p>

Provide Css to the div..将 Css 提供给 div..

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM