the text is centered on the image using an absolute "positioning" on the container block and a X-Y translation (a CSS classic).Original image and text overlay are defined by. Important note: The image-overlay container MUST be "positioned" itself (here relative) in order to position its own elements.
![overlay text on image html overlay text on image html](https://res.cloudinary.com/practicaldev/image/fetch/s--KTX4GStd--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://res.cloudinary.com/practicaldev/image/fetch/s--fV0Gxovq--/c_imagga_scale%2Cf_auto%2Cfl_progressive%2Ch_420%2Cq_auto%2Cw_1000/https://thepracticaldev.s3.amazonaws.com/i/yytx594giep29wjtbi9y.png)
In this article, I replaced the "width: 100% " by "width: 80% margin: auto " to add margins. The overlay-image class allows you to set the global container when not using a page builder.
#Overlay text on image html how to
How to display the original or simple text overlay? or your Divi page options if the mechanism is only used at a specific location.style.css file of your child theme if you work with WordPress,.style.css file included in your HTML file if you work directly in HTML,.The code below is to be included in your styles definition: CSS code: text overlay and text/image change on hover * Color background and text overlay on hover */ The code below also includes encapsulating link tags to make images clickable, but you can remove them if not needed. With a builder, it can be replaced by an existing container block (for example it could be the Divi "code" module, to which we simply add the overlay-image class). On a page written without a page builder (HTML page or simple WordPress theme), for instance like this article, it is essential to define it in order to properly include original content and overlay within the page. image/text overlay block displayed on mouse hover.The overlay-image class container encapsulates all the necessary structure:
![overlay text on image html overlay text on image html](https://i1.wp.com/www.csscodelab.com/wp-content/uploads/2020/03/corner-triangle-slide-overlay-css-text-reveal.png)
HOVER HTML code: original content and overlay Content structure