M
M
misha9797972018-04-03 22:09:41
css
misha979797, 2018-04-03 22:09:41

How to insert text inside an image?

How to insert text inside an image?

<div class="content1-down2 col-sm-4">
            <img src="img/vector-smart-object.png" alt="">
            <h4>15</h4>
            <p>Скидка<br>постоянным<br>клиентам</p>
          </div>

Image vector-smart-object.png :
5ac3d13a3a3b3060840937.jpeg
tried it with positioning and it didn't work
.content1-down2 img{
position: relative;
}
.content1-down2 h4{
position: absolute;
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
Lam Besis, 2018-04-03
@misha979797

It's not very clear what exactly you mean, but if suddenly I understood you, then here it is.
Or make this image a background image:

.content1-down2 {
  background-image: url(../img/vector-smart-object.png);
}

Or, if it is critical for you in html markup, position the image absolutely and stretch it to the size of the parent:
.content1-down2 {
  position: relative;
}
img{
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

A
Artem Spiridonov, 2018-04-03
@customtema

Offhand options:
- make the image the background of the div
- absolute positioning

A
adrenalinruslan, 2018-04-04
@adrenalinruslan

.content1-down2{
position: relative;
}
.content1-down2 h4{
position: absolute;
top: 0;
left:0;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question