Answer the question
In order to leave comments, you need to log in
Bootstrap 4. How to position text in the middle of a scalable image?
Good afternoon!
There is an image (background) that scales while maintaining aspect ratio when the browser window is resized.
I can’t insert text in the center (
I am writing on Bootstrap 4, for sure this functionality already exists there.
I do this:
<div class="container-fluid">
<img src="img/image.jpg" class="w-100" alt="">
<div class="row">
<h1 class>Текст</h1>
</div>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
Bootstrap has nothing to do with it. You need to use position: absolute in order to overlay text on the image in your example. You can also make a div with the background of the specified image, set a static (or minimum) height for this div, and place the text inside. And write to the div itself:
display: inline-flex;
display: -moz-inline-box;
display: -ms-inline-flexbox;
display: -webkit-inline-flex;
align-items: center;
-ms-flex-align: center;
-webkit-align-items: center;
justify-content: center;
-webkit-justify-content: center;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question