猿问

如何将文字放在图片前面

我是编码初学者,我想将文本放在图片前面。

我正在使用科莫多。这是我的代码:

繁花不似锦
浏览 104回答 3
3回答

临摹微笑

我在这里为您提供了一个解决方案,但它可以通过多种不同的方式实现。.bandeau {&nbsp; position: relative;&nbsp; text-align: center;}h1 {&nbsp; position: absolute;&nbsp; top: 10%;&nbsp; left: 20%;&nbsp; color: red;}h2 {&nbsp; position: absolute;&nbsp; top: 25%;&nbsp; left: 20%;&nbsp; color: red;}h3 {&nbsp; position: absolute;&nbsp; top: 40%;&nbsp; left: 20%;&nbsp; color: red;}<div id="bandeau">&nbsp; &nbsp;<div id="contenu">&nbsp; &nbsp; &nbsp; <img src="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885_1280.jpg" alt="photo d'aceuil">&nbsp; &nbsp; &nbsp; <h1>Pour ma nadette</h1>&nbsp; &nbsp; &nbsp; <h2>Mon amoureuse</h2>&nbsp; &nbsp; &nbsp; <h3>Je t'aime</h3>&nbsp; </div></div>

手掌心

应该是这样,如果您需要更多帮助,请发表评论。这会将文本放置在图像上并将其置于中心。<div>&nbsp; <img src="">&nbsp; <h1>Text</h1> <!-- This will positon text over image --></div>div {&nbsp; position: relative;&nbsp; text-align: center;}image {&nbsp; position: absolute;&nbsp; top: 50%;&nbsp; left: 50%;&nbsp; transform: translate(-50%, -50%);}

小怪兽爱吃肉

根据您的标签,这是一个 CSS 解决方案。将其添加到您的<head></head>标签之间。<style>&nbsp; &nbsp;#contenu::after {&nbsp; &nbsp; &nbsp; content: "words";&nbsp; &nbsp;}</style>
随时随地看视频慕课网APP

相关分类

Html5
我要回答