html - 如何显示图像和文本与行之间的文本内联

标签 html css asp.net

我有一张 20 x 50 像素的图像,并希望将其与一些字体大小为 20 像素的文本内联显示。
我想要文本在行的中间,文本粘在较低的位置,我想要它在行的中间。由于图像高度为 50px,字体为 20px。
我尝试填充图像(Padding-top:20px;)但它会影响整行。

    <div  style="display:inline; ">
      <a href="./waterbill" title="Water Bill Detail"> 
       <img style="width: 20px; height: 50px; padding-top: 25px;" src="images/useful/phed-water-drop.png" />
      </a>&nbsp; 
   </div>
  <div  style="display:inline; white-space:nowrap;">
    <a href="./waterbill" title="Water Bill Detail"> Water Bill Details </a>
  </div>

Is there any way to show text in the middle (y axis) of the line, with image in its left ?

最佳答案

您可以使用vertical-align 作为:

<div style=" margin-top: 25px;">
  <div style="display: inline; white-space: nowrap;">
   <a href="./waterbill" title="Water Bill Detail">
      <img style="width: 20px; height: 30px; vertical-align: middle;" src="images/useful/phed-water-drop.png"/>
   </a>&nbsp;
  <a href="./waterbill" title="Water Bill Detail" style="vertical-align: sub;">Water Bill Details </a>
  </div>
</div>

关于html - 如何显示图像和文本与行之间的文本内联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33480100/

相关文章:

javascript - Dart 中未定义 new Image()

javascript - 图像预览和网络 worker

html - Web Sockets 服务器端的使用/实现

php - 使用 <ul><li> 的动态建议列表在桌面上适用于所有浏览器,但不适用于 iphones 移动设备

jquery - Bootstrap 侧边栏 visible-xs

javascript - 如何创建动态页面? Javascript 还是 ASP.NET?

c# - 如何为 Web API 2 异步操作中的异常获取正确的堆栈跟踪?

php - 使用数据库将数据形成表

javascript - 单击按钮时显示/阻止消息

asp.net - 即使禁用 IIS 压缩,为什么 ScriptResource.axd 仍会被压缩?