I am developing a portfolio website. I tried to put some text over an image. I put the picture (#projet-indiv
) in position: relative
and the text (#texte_projet
) in position: absolute
.
.projet-indiv {
display: flex;
flex-direction: row;
justify-content: space-around;
width: 100%;
margin-bottom: 60px;
}
.texte-projet {
position: absolute;
z-index: 15;
}
.images-projet {
position: relative;
width: 50%;
}
<div class="images-projet">
<img src="https://placekitten.com/300/230" style="height: 230px; width: 300px;">
<div class="texte_projet">
<p>Projet</p>
</div>
<p>๐ Dataviz</p>
</div>
2
Answers
Link to main stackoverflow answer : Display text on MouseOver for image in html
The simplest solution for you is to use
title
attribute :Or else to use CSS hover :
Apart from spelling the class name correctly, you need to use position parameters like
top
orbottom
andleft
orright
(all in relation to the relative-positioned parent) to place the absolutely positioned text where you want it: