gpt4 book ai didi

CSS 问题 : Center Text in a box with Image

转载 作者:行者123 更新时间:2023-11-28 14:41:44 24 4
gpt4 key购买 nike

有人可以帮忙吗?我正在努力让一些 CSS 代码发挥作用。

我需要三个盒子;他们需要看起来像图片中的样子

this is what it should look like

但是当我运行我的代码时,文本总是在图像下方。

谁能告诉我我做错了什么? :

https://codepen.io/arminx2/full/wYPxZe

</div><div style="margin-top: 16px; background: white; box-shadow: rgba(76, 76, 76, 0.25) -1px 1px 2px 1px; padding: 12px; height: 70px; border-radius: 2px; flex-direction: row; align-items: center; cursor: pointer; opacity: 1; transition: all 1s linear 0s;"><img src="http://relationshiphero.com/images/sageTeal.png" style="height: 32px; width: 32px; margin-right: 16px;"><div><div style="font-size: 12px; color: rgb(5, 26, 90); margin-bottom: 2px;">16% better value</div><div style="color: rgb(0, 112, 232); font-size: 14px; font-weight: bold;">Sage - 60 minutes</div></div><div style="margin-left: auto; margin-right: 8px; color: rgb(0, 112, 232);"><img src="/images/triangleRight.png" style="width: 16px; height: 16px;"></div></div><div style="margin-top: 16px; background: white; box-shadow: rgba(76, 76, 76, 0.25) -1px 1px 2px 1px; padding: 12px; height: 70px; border-radius: 2px; flex-direction: row; align-items: center; cursor: pointer; opacity: 1; transition: all 1s linear 0s;"><img src="http://relationshiphero.com/images/heroTeal.png" style="height: 32px; width: 32px; margin-right: 16px;"><div><div style="font-size: 12px; color: rgb(5, 26, 90); margin-bottom: 2px;">38% better value</div><div style="color: rgb(0, 112, 232); font-size: 14px; font-weight: bold;">Hero - 240 minutes</div></div><div style="margin-left: auto; margin-right: 8px; color: rgb(0, 112, 232);"><img src="http://relationshiphero.com/images/triangleRight.png" style="width: 16px; height: 16px;"></div></div></div></div><div class="rightSec"><div style="position: absolute; height: 450px; width: 341.8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px; background-image: url(&quot;/images/home/howItWorks5.jpg&quot;); background-size: cover; background-position: center top;"></div></div></div></div>

我不确定我做错了什么。如果有人可以看一下这个,我将不胜感激。

谢谢

最佳答案

您需要为使用 flexbox 的元素添加 display: flex; 属性

关于CSS 问题 : Center Text in a box with Image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52831267/

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