如何大小的段落与图像相同的高度
试图使段落的大小与右图的大小相同。目前是段落的底部更改大小,但顶部是固定的
CSS代码是
.kid{
display: flex;
position: relative;
float: right;
height: auto;
max-width: 50%;
}
.paragraph{
display: flex;
margin-right: 50%;
font-size-adjust: auto;
background-color: #3498db;
color:white;
font-style: italic;
font-weight: bold;
}
,我的HTML代码是
<div>
<img class = "kid" src="kid%20playing%20toy%20pic.jpg">
</div>
<div class = "para">
<section class="paragraph">
<p> "text" </p>
</section>
</div>
Trying to get the paragraph to be the same size as the image on the right as it. currently it is the bottom of the paragraph changes size but the top is fixed
my CSS code is
.kid{
display: flex;
position: relative;
float: right;
height: auto;
max-width: 50%;
}
.paragraph{
display: flex;
margin-right: 50%;
font-size-adjust: auto;
background-color: #3498db;
color:white;
font-style: italic;
font-weight: bold;
}
and my HTML code is
<div>
<img class = "kid" src="kid%20playing%20toy%20pic.jpg">
</div>
<div class = "para">
<section class="paragraph">
<p> "text" </p>
</section>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为您希望图像的大小在段落的长度上具有动态性,所以我将使用2列
flex> flex
布局,第二个div包含图像作为background-background-image 。这样做是响应的,因为
image-div
的高度会随着段落变得越来越大。Because you want the size of the image to be dynamic with the length of the paragraph, I would use a 2-column
flex
layout with the second div containing the image asbackground-image
. Do it this way is responsive because the height of theimage-div
will change as the paragraph gets smaller or larger.尚不清楚您实际想要什么。使用Flex。
not entirely clear what you actually want. Use flex.