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 does not recognize the pointer-events
property, so you need to use a javascript backup like this if necessary. In addition, some old mobile browsers / old IE do not support position: fixed
, so you need another javascript reserve to place the image in the center of the viewport.
Aaron source share