CSS问题:将文本放在带有图像的框中

时间:2018-10-16 08:38:07

标签: css image button center

有人可以帮忙吗? 我正在努力使一些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>

我不确定自己在做什么错。如果有人可以看一下,我将不胜感激。

谢谢

1 个答案:

答案 0 :(得分:1)

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