我有一只潜水艇在左边漂浮.在div里面,我有一个图像.在差异之后是一段.

我希望这一段能围绕图片展开,但我看到了大量的空白.

.class-0-568 {
  float: left;
}

.class-0-569 {
  padding-right: 2%;
  width: 33%;
}

.class-0-570 {
  line-height: 1.2em;
  margin-top: 0.2816004em;
}
<div class="class-0-568" id="id-0-553">
  <img alt="" class="class-0-569" id="id-0-554" src="https://i.postimg.cc/BZYZRfKP/image-0-4.jpg">
</div>
<p class="class-0-570" id="id-0-555">These offer a description of who you are</p>

这是上面的输出

Output

如果我将float属性设置为img,那么它将按预期工作.

Correct Output

我不明白为什么.谁能帮帮我吗?

PS:JSFIDLE链接如果有人想玩:

https://jsfiddle.net/chid1989/say7pzqe/#&togetherjs=z8iIlaQmNz

EDIT

我试着用 chromium 来判断这些元素.显然,div正在占用额外的空间.但我不知道为什么.

Inspection

推荐答案

你的图片宽度(由.class-0-569级造成)为33%.但这是它的container/父元素,即浮动的.class-0-568元素.

将33%的宽度应用于图像的parent(.class-0-568),将.class-0-568%的宽度应用于图像本身:

.class-0-568 {
  float: left;
  width: 33%;
}

.class-0-569 {
  padding-right: 2%;
  width: 100%;
  height: auto;
}

.class-0-570 {
  line-height: 1.2em;
  margin-top: 0.2816004em;
}
<div class="class-0-568" id="id-0-553">
  <img alt="" class="class-0-569" id="id-0-554" src="https://i.postimg.cc/BZYZRfKP/image-0-4.jpg">
</div>
<p class="class-0-570" id="id-0-555">These offer a description of who you are</p>

注释后添加:实际上更简单的替代方法是在不使用包装器div的情况下浮动图像本身:

#id-0-554 {
  float: left;
  width: 33%;
  margin-right: 2%;
}


.class-0-570 {
  line-height: 1.2em;
  margin-top: 0.2816004em;
}
 <img alt="" class="class-0-569" id="id-0-554" src="https://i.postimg.cc/BZYZRfKP/image-0-4.jpg">
<p class="class-0-570" id="id-0-555">These offer a description of who you are</p>

Html相关问答推荐

html中背景色的全单元格R中的Rmarkdown表

如何从ThymeLeaf模板中分离CSS

Angular 分量被循环

获得一个css框,以便在页面太小时不再粘在页面的角落.

VBA从公共Google Drive地址下载文档-.Click事件(?)

R-markdown中的非顺序列表

MatSnackBar: colored颜色 不起作用

禁用的文本区域会丢失换行符

带下划线的文本应该有延长的下划线,以使其图像悬停

元素在向x提供溢出时被隐藏

在css中是否可以在遮罩图像中结合线性渐变和径向渐变?

如果最后一行的卡数少于其他行,则在使用flex grow使卡在调整大小时拉伸后,flex卡的宽度将被拉伸

带有图像的虚线边框

如何避免链接在悬停 timeshift 动,同时增加导航栏中的字体大小?

如何使我的下拉菜单响应?

使用模板循环每行列出 3 个 bootstrap 卡

每次按下按钮时减小字体大小的 jquery 函数

变换元素以适应高度(Angular,SCSS)

左右图像,响应页面大小并居中

如何在 about:blank 网站上设置页面标题