HTML:为什么文字比图片低一段? (有图)

标签 html css

<分区>

我遇到了以下问题:

这是我目前得到的结果:

enter image description here

它是由这段 HTML 代码生成的:

.box-2 /*targeting class from HTML*/
    {
    	border:8px dotted #ccc;
    }
<!--Who we are-->
<div id="whoweare" align="center" class="box-2">
  <div align="center>	
    <font color="#534f4f" size="+1">	
      <h1 id="txt_whoweare_headline">Who we are</h1>
    </font>
  </div>
  <div style="padding-left: 15px; padding-right: 15px">	
    <table border="0">
      <tr> <!--tablerow-->
        <th width=400px>
          <div align="center">	
            <img 
              src="./img/me.png"
              width=60%>	
          </div>
        </th>	
        <td width=400px>
          <div align="justify">								
            <font color="#534f4f" size="+2" >	
              <h3>Julius Tolksdorf</h3>
              <div id="txt_whoweare_body1">CEO of innomotion media and head of software development.</div> 
              <div id="txt_whoweare_body2">
                He will be your primary contact during the planning and development processes.
                Julius has already finished about 20 apps, games & web pages and has years of experience being an Android & Unity developer.
              </div>
            </font>
          </div>
        </td>	
      </tr> <!--for padding-->
        <tr height=20px/>
      </tr>

    </table>
  </div>
</div>

正如您可能看到的那样,“JULIUS TOLKSDORF”的文本从左侧图像下方的一行开始。当然,我希望他们都从同一条线开始。 CSS 就是这样:

.box-2 /*targeting class from HTML*/
{
    border:8px dotted #ccc;
}

如果有人指导我解决上述问题,我将不胜感激。

谢谢你:)

最佳答案

标题标签默认有边距,所以你的 <h3>也有这个 margin 。您的问题的解决方案是设置 margin到顶部的 0。

此代码类似于:

h3 {
    margin-top: 0;
}

注意:这将删除页面中所有 h3 元素的上边距。

关于HTML:为什么文字比图片低一段? (有图),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56126912/

上一篇:html - 垂直拉伸(stretch)div内的div

下一篇:Javascript : How to display a default tab content but hide other tab content

相关文章:

css - IE8 css ssues 菜单栏显示不正确

javascript - 如何更改输入的字体?

html - 垂直居中带有背景图像的跨度

html - Bootstrap透明菜单

html - 弹出框、模态组件或页面的 Ionic 4 自定义样式

html - 如何让整个 DIV 可以单击并重定向到下一页

javascript - 如何使用 jquery 删除父 div?

python - 在 python 中打印列表中的所有项目时出现问题

html - 带有背景图像的 Twitter Bootstrap 嵌套容器 - 响应式

css - 为什么我的图像没有正确排列?