Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to watermark/overlay image on an html page?

Tags:

html

jquery

css

Is it possible to somehow watermark an html page with a semi-transparent image that still lets through user interaction on the page behind it? Contradictory, and doesn't seem possible without some complicated scripting, but maybe I'm missing something.

like image 839
Random Avatar asked Mar 29 '12 23:03

Random


1 Answers

This will work for most modern browsers:

div#watermark {
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: 99999;
    background: url('path/to/image.png') center center no-repeat;
    pointer-events: none;
}

Unfortunately, IE doesn't recognize the pointer-events property, so you need to use a javascript fallback like this one if needed. Also, some older mobile browsers/old IE don't support position: fixed, so that'll also require another javascript fallback to position the image in the center of the viewport.

like image 71
Aaron Avatar answered Oct 15 '22 17:10

Aaron