【发布时间】:2019-06-12 03:14:22
【问题描述】:
我对此很陌生
我正在尝试在具有响应式背景颜色的浮动右图像旁边创建文本。 此部分将作为文章的一部分显示,但样式仅适用于此部分。
下面的代码似乎可以工作,但是我希望文本与图像垂直对齐。使文字显示在图像的中间。
我似乎无法做到这一点
我已经定义了
<img style="float: right; vertical-align: middle;">
这是代码 (https://codepen.io/Masseve/pen/LMoMyW/)
<div id="blogcontent">
<img style="float: right; vertical-align: middle;" src="https://image.shutterstock.com/z/stock-photo-city-interchange-closeup-at-night-beautiful-transport-infrastructure-background-267836915.jpg" width="700"/>
<div id="textcontent">
<H1> A Title </h1>
<P>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. <br> <br>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</P>
</div>
</div>
#blogcontent {
border-radius: 4px;
background-color: #ebe9e5;
display: inline-table;
}
#textcontent {
Padding: 20px
}
【问题讨论】:
-
你好,你不应该在这个工作中使用浮点数,你可以用 flex 查看下面的答案,如果你想了解更多关于 flexbox 的信息,请点击这里css-tricks.com/snippets/css/a-guide-to-flexbox