I'm doing tests with text positioning on an image. I have this:
This I get with this code. In html:
<main>
<div class="caja">
<img src="smartphones.png" alt="" >
<div class="texto">
<h2>texto</h2>
<p>Lorem, ipsum dolor.</p>
</div>
</div>
</main>
In the CSS:
.caja{
position: relative;
}
img{
width: 100%;
}
.texto{
color: red;
position: absolute;
bottom: 10px;
left: 50px;
font-size: 3rem;
}
Good. With this if I resize the screen the image is resized. Being something like this (depending on the screen size, the text will obviously have a different position):
The question is: Is there any way that the text always stays in the same position and has a size according to the size of the image? I have the solution of putting half queries and positions and text size chords. But could it be done automatically? Any bookstore to put text on images?
I've tried to put the font-size as vw and something fixes ... but even so it's not what I want.
Greetings and thanks.