html - HTML:为什么文本比图像低一个段落?(附图片)
问题描述
我有以下问题:
这是我目前得到的结果:
它由以下 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
顶部设置为 0。
代码类似于:
h3 {
margin-top: 0;
}
注意:这将删除页面中所有 h3 元素的上边距。
推荐阅读
- python - 后序遍历此代码如何到达打印行 - Python
- python - 使用 reticulate 的 Rshiny 应用程序中的 virtualenv/condaenv
- azure - docker 注册表的细粒度权限
- ansible - sshfs 没有使用 ansible playbook 挂载目录
- animation - 如果用户点击错误的 btn 或小部件,Flutter 中是否有办法向用户显示点击位置?
- gatling - 使用动态 where 子句的 Gatling JDBC
- pandas - 如何使用 Pandas 查找缺失的时间值
- c++ - 具有类型别名的循环依赖
- mysql - 如何使用 MYSQL 将字符串拆分为表中的多行?
- material-ui - 使用 react-select Select 在同一个网格中时,文本字段不会拉伸