gpt4 book ai didi

css - 响应式垂直对齐向右浮动图像和文本

转载 作者:行者123 更新时间:2023-11-28 00:34:39 24 4
gpt4 key购买 nike

我对这个很陌生

我正在尝试在具有响应式背景颜色的 float 右侧图像旁边创建文本。此部分将显示为文章的一部分,但样式仅适用于此部分。

下面的代码似乎有效,但我希望文本与图像垂直对齐。使文字显示在图像的中间。

我好像做不到这一点

我已经定义了 <img style="float: right; vertical-align: middle;">

Picture of code rendered

这是一个代码(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
}

最佳答案

这是一个小例子:D

.wrapper {
display: flex;
flex-flow: row wrap;
}

.main {
text-align: left;
background: deepskyblue;
flex:1.5
}


.aside-1 {
background: purple;
flex:1
}
.image{
width:100%;
height:100%;
background-image:url('https://image.shutterstock.com/z/stock-photo-city-interchange-closeup-at-night-beautiful-transport-infrastructure-background-267836915.jpg');
background-size:cover;
}

@media all and (min-width: 600px) {
.aside { flex: 1; }
}

/*@media all and (min-width: 800px) {
.main { flex: 3 0px; }
.main { order: 1; }
.aside-1 { order: 2; }

}*/
<div class="wrapper">
<article class="main">
<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>
<br>
<br>
</article>
<aside class="aside aside-1">
<div class="image"></div>
</aside>
</div>

关于css - 响应式垂直对齐向右浮动图像和文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54244089/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com