HTML/CSS: Text side overlay on images

I was looking for an HTML zoom effect when I instead came across this overlay effect on the W3School tutorial pages. Both examples will need an “img class” container in the code. The first example contains a URL embedded picture which was pasted into the code after obtaining the online address of the image.

Screen Shot of Copy Image Address of an online image
Screen Shot of Copy Image Address of an online image

This is done by right-clicking on an online image and select ‘Copy Image Address’. Make sure the URL address copied ends with .jpg.

The second example is one of my images from my blog Media Library, which was added using the Add Media button in the blog editor.

See HTML code outlined below.

Text Slide via a Left Overlay

Hover the mouse over the picture to see the HTML effect.

Game of Thrones 2017 poster

Hello World

 

picture of coffee bean I use in my coffee

Hello Coffee
HTML:
/*text overlay effect w3schools.com/howto/howto_css_image_overlay.asp
*/
<div class="container">
<img class="image" src="https:image here" />
<div class="overlay">
<div class="text">Add your overlay text here</div>
</div>
</div>

CSS:
/*text hover overlay w3schools.com/howto/howto_css_image_overlay.asp
*/
.container:hover .overlay {
width: 100%;
}

.text {
white-space: nowrap;
color: white;
font-size: 20px;
position: absolute;
overflow: hidden;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}</div>
</div>

 


References

Game of Thrones (2017) poster of Sansa Stark. (2017). [image] Available at: https://winteriscoming.net/2017/06/21/game-of-thrones-season-7-winterishere-12-character-posters/ [Accessed 29 Aug. 2017].

W3schools.com. (n.d.). How To Create Image Hover Overlay Effects. [online] Available at: https://www.w3schools.com/howto/howto_css_image_overlay.asp [Accessed 29 Jul. 2017].

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s