How to group text with image

Asked

Viewed 34 times

0

Problem: I created a modal to display some information and text about the image. I’m not getting the text to be in front of the image.

Solution: Leave text in front of the image. This image is loaded as soon as it opens the page.

HTML/CSS:

.corpoModal {
width: 900px;
float: left;
position: relative;
}

#textoImagem {
padding: 16px;
}
#imagem {
width: 900px;
}

.texto-modal {
position: absolute;
top: 0;
left: 0;
/*cor apenas para exmplo*/
color: #ff0000;
}
     <!--Modal: Produto em liquidação-->
    <div class="modal fade" id="produtoLiquidacao" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog modal-lg" role="document">

            <!--Content-->
            <div class="modal-content">

                <!--Body-->
                <div class="modal-body mb-0 p-0 corpoModal">

                    <div class="texto-modal">
                        <h2 id="textoImagem">Texto Aqui</h2>
                    </div>

                    <div class="embed-responsive embed-responsive-16by9 z-depth-1-half">

                        <img id="imagem" src="~/assets/img/product/promocoes.jpg" style="width: 900px;"/>
                    </div>

                </div>

                <!--Footer-->

            </div>
            <!--/.Content-->

        </div>
    </div>

Imagery: inserir a descrição da imagem aqui

  • 1

    need to use position: absolute in the element that has the text, and then margin to adjust exactly where the text appears. Or you can place the text inside it div that contains the image and use only the property margin to position

  • But the text is already in front of the image... http://prntscr.com/oljq7t I don’t understand

  • 1

    Read, this tutorial on the position property of the CSS on https://www.w3schools.com/css/css_positioning.asp, will help you position the text on the image or other content.

  • Hello Hugo, so this same code in my project was appearing behind the image I don’t know why. More I managed to resolve thanks for the attention

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.