css – text in an img in html


Here are some examples of how you can do this. In practice, you create a container in which you insert it div with the content of the text you want to insert, using the classes in which divin this case in position absolute Definition with the help of up, down, left, right,

In the case of the focused text, I apply a technique that I personally like very much, which is to be set above: 50% and a left: 50% Add a transfer from -50% on the two axes: transform: translate (-50%, -50%);

/ * Container * /
.Container {
Position: relative;
Align text: center;
Color white;
}
/ * bottom left * /
bottom left {
Position: absolutely;
below: 8px;
left: 16px;
}
/ * top left * /
.top-left {
Position: absolutely;
above: 8px;
left: 16px;
}
/ * top right * /
.top-right {
Position: absolutely;
above: 8px;
right: 16px;
}
/ * bottom right * /
.bottom-right {
Position: absolutely;
below: 8px;
right: 16px;
}
/ * centered * /
centered {
Position: absolutely;
Peak: 50%;
left: 50%;
transform: translate (-50%, -50%);
}

centered below {
Position: absolutely;
below: 6px;
left: 50%;
transform: translatex (-50%);
}
snow
Top left
Top right
centered
This is the text that does not have to leave the edge, I mean, overflowing: Lorem ipsum pain sitting amet, consectetur adipisci elit, thirst eiusmod temporal incidunt ut labore and dolore magna aliqua. You need to minimize but not be able to minimize yourself, do an exercise to improve your health.

Add a new class there: centered belowUse the in this class translatex (-50%) with a left (50%) to center it. and I stop below: 6px; this allows you to have the div at a minimum distance from the background.

I hope it helps you, success

This code was taken from this page in English.