简体   繁体   English

如何将文字对齐到fontawesome图标

[英]how do I align text to fontawesome icon

i searched through similar questions and still could not find a solution. 我搜索了类似的问题,但仍然找不到解决方案。 I have a fontawesome icon that triggers an expanding form. 我有一个能触发扩展表单的字体图标。

      <div class='create-inventory-form'></div>
              <div class='icon fa fa-pencil' id='form-container'>  
          <!-- <span>Create</span>  I tried this but it only shows on the pop-up form-->
                <span class='icon fa fa-close' id='form-close'></span>
                <div id='form-content'>
                  <div id='form-head'>
                    <h1 class='pre'>Add New Item to Inventory</h1>
                    <p class='pre'>Good choice...</p>
                    <h1 class='post'>Thanks!</h1>
                    <p class='post'>I'll be in touch ASAP</p>
                  </div>
                  <form>
                    <input class='input name' name='user_name' placeholder='Your name please' type='text'>
                    <input class='input email' name='user_email' placeholder='A contact email' type='text'>
                    <select class='input select' name='subject'>
                      <option disabled=''>What shall we talk about?</option>
                      <option selected=''>About a new project</option>
                      <option>About a job opportunity</option>
                      <option>Let's do this over a coffee</option>
                    </select>
                    <textarea class='input message' placeholder='How can I help?'></textarea>
                    <input class='input submit' type='submit' value='Send Message'>
                  </form>
                </div>
              </div>

this is what i have with the code above 这就是我上面的代码 在此处输入图片说明

this is what i want to create 这就是我要创造的 在此处输入图片说明

If you want the respective text to be vertically aligned center with the icon so you have to set a css property Vertical align : middle to your icon class.in your case 如果要使各个文本与图标垂直居中对齐,则必须设置一个css属性Vertical align:在图标类的中间。

.fa-pencil:before {
   content: "\f040";
   vertical-align: middle;
}

Jsfiddle 的jsfiddle

.fa{
display:block;
text-align:center;
}

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

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