Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何对齐位于div内部的两个跨距的顶部?_Html_Css_Vertical Alignment - Fatal编程技术网

Html 如何对齐位于div内部的两个跨距的顶部?

Html 如何对齐位于div内部的两个跨距的顶部?,html,css,vertical-alignment,Html,Css,Vertical Alignment,我试图使cat图片的顶部与下图中文本的顶部垂直对齐: 如你所见,文本低于图片 以下是CSS和HTML: 2019年获奖者(14 pt Arial Bold) Erionsequiat。我每天都要喝一杯,这是一种非暂时性的非酒精饮料,。(10分Arial常规) 试试这个: .html 我建议您删除所有样式属性并将其放在类中:)最好使用flex-box而不是float和vertical-align <div class="box" style='display: flex;'>

我试图使cat图片的顶部与下图中文本的顶部垂直对齐:

如你所见,文本低于图片

以下是CSS和HTML:


2019年获奖者(14 pt Arial Bold)

Erionsequiat。我每天都要喝一杯,这是一种非暂时性的非酒精饮料,
。(10分Arial常规)

试试这个:

.html


我建议您删除所有样式属性并将其放在类中:)

最好使用flex-box而不是float和vertical-align

<div class="box" style='display: flex;'>
    <img width="120px" height="120px" src="./5 Bilder_Logos/cat.jpeg"/>
    <div class="content" style="margin-left: 15px;">
        <p class=EinfAbs style='margin-top:0;'><b><span lang=EN-US style='font-size:14.0pt;line-height:120%;font-family:"Arial","sans-serif";color:#21438B;letter-spacing:.4pt'>AWARD WINNER 2019 </span></b><b><span lang=EN-US style='font-size:14.0pt;line-height:120%;font-family:"Arial","sans-serif";color:red;letter-spacing:.4pt'>(14 pt Arial Bold)</span></b><b><span lang=EN-US style='font-size:14.0pt;line-height:120%;font-family:"Arial","sans-serif";color:#21438B;letter-spacing:.4pt'><o:p></o:p></span></b></p>
        <p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Erionsequiat. Ibus apel everehe nectinihil et, quia <br>nonestrupta cuptaesed que peri nam nonsedi tempore,  <br>ut enimaione nonsedi vitat. <span style='color:red'>(10 pt Arial Regular)</span>
    </div>
</div>

2019年获奖者(14分Arial粗体)

Erionsequiat。我每天都要喝一杯,这是一种非暂时性的非酒精饮料,
。(10分Arial常规)


并使用
对齐项目:flex start
对齐方框内容。

删除浮点数并使用
显示:内联块
@temaniaf如果我刚刚尝试了此操作,并且图像现在位于文本上方,我绝对不想更新,请稍后再试look@DavidJ. 为什么不使用position:relative并从顶部移动图像?您应该首先清理HTML,然后CSS将能够正常工作
.example {
  display: inline-block;

  img, p {
    vertical-align: top;
  }
}
<div class="box" style='display: flex;'>
    <img width="120px" height="120px" src="./5 Bilder_Logos/cat.jpeg"/>
    <div class="content" style="margin-left: 15px;">
        <p class=EinfAbs style='margin-top:0;'><b><span lang=EN-US style='font-size:14.0pt;line-height:120%;font-family:"Arial","sans-serif";color:#21438B;letter-spacing:.4pt'>AWARD WINNER 2019 </span></b><b><span lang=EN-US style='font-size:14.0pt;line-height:120%;font-family:"Arial","sans-serif";color:red;letter-spacing:.4pt'>(14 pt Arial Bold)</span></b><b><span lang=EN-US style='font-size:14.0pt;line-height:120%;font-family:"Arial","sans-serif";color:#21438B;letter-spacing:.4pt'><o:p></o:p></span></b></p>
        <p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Erionsequiat. Ibus apel everehe nectinihil et, quia <br>nonestrupta cuptaesed que peri nam nonsedi tempore,  <br>ut enimaione nonsedi vitat. <span style='color:red'>(10 pt Arial Regular)</span>
    </div>
</div>