首页 > Web开发 > 详细

js添加水印(文字+图片水印效果)

时间:2020-08-24 14:34:56      阅读:70      评论:0      收藏:0      [点我收藏+]
     /**
         * 文字加图片水印效果
         * id 要加水印的区域
         * watermarkImg 水印为图片的图片url
         * watermarkText 水印文字
         */
        
      
   function watermarkWord(id,watermarkImg , watermarkText) {
            var screenHeight = window.screen.height
            var watermarkImg = watermarkImg ;
            var watermarkText =  watermarkText;
            
            if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/9./i) == "9.") {
                var step = 180 / 480 * screenHeight;
                for (var i = 0; i <= parseInt($("body").height() / step); i++) {
                    $(‘body‘).append(‘<div style="z-index:-999;width:100%;text-align:center;opacity:0.2;color:#000;position:absolute;top:‘ + step * (i) + ‘px;font-size:2em;transform:rotate(-30deg); -ms-transform:rotate(-30deg); -o-tranform:rotate(-30deg); -webkit-transform:rotate(-30deg); -moz-transform:rotate(-30deg);filter:progid:DXImageTransform.Microsoft.Alpha(opacity=10));">‘ + watermarkText + ‘<br /><img style="width:8em;" src="‘ + watermarkImg + ‘" /></div>‘);
                }
            } else {
                var step = 180 / 480 * screenHeight;
                for (var i = 0; i <= parseInt($("body").height() / step); i++) {
                    $(‘body‘).append(‘<div style="z-index:-999;width:100%;text-align:center;opacity:0.5;color:#000;position:absolute;top:‘ + step * (i) + ‘px;font-size:2em;transform:rotate(-30deg); -ms-transform:rotate(-30deg); -o-tranform:rotate(-30deg); -webkit-transform:rotate(-30deg); -moz-transform:rotate(-30deg);filter:progid:DXImageTransform.Microsoft.Alpha(opacity=10) progid:DXImageTransform.Microsoft.Matrix(sizingMethod=\‘auto expand\‘, M11=0.866025404, M12=0.5, M21=-0.5, M22=0.866025404);">‘ + watermarkText + ‘<br /><img  style="width:8em;" src="‘ + watermarkImg + ‘" /></div>‘);
                }
            }
        }

  

技术分享图片
   function watermarkWord(id,watermarkImg , watermarkText) {
            var screenHeight = window.screen.height
            var watermarkImg = watermarkImg ;
            var watermarkText =  watermarkText;
            
            if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/9./i) == "9.") {
                var step = 180 / 480 * screenHeight;
                for (var i = 0; i <= parseInt($("body").height() / step); i++) {
                    $(‘body‘).append(‘<div style="z-index:-999;width:100%;text-align:center;opacity:0.2;color:#000;position:absolute;top:‘ + step * (i) + ‘px;font-size:2em;transform:rotate(-30deg); -ms-transform:rotate(-30deg); -o-tranform:rotate(-30deg); -webkit-transform:rotate(-30deg); -moz-transform:rotate(-30deg);filter:progid:DXImageTransform.Microsoft.Alpha(opacity=10));">‘ + watermarkText + ‘<br /><img style="width:8em;" src="‘ + watermarkImg + ‘" /></div>‘);
                }
            } else {
                var step = 180 / 480 * screenHeight;
                for (var i = 0; i <= parseInt($("body").height() / step); i++) {
                    $(‘body‘).append(‘<div style="z-index:-999;width:100%;text-align:center;opacity:0.5;color:#000;position:absolute;top:‘ + step * (i) + ‘px;font-size:2em;transform:rotate(-30deg); -ms-transform:rotate(-30deg); -o-tranform:rotate(-30deg); -webkit-transform:rotate(-30deg); -moz-transform:rotate(-30deg);filter:progid:DXImageTransform.Microsoft.Alpha(opacity=10) progid:DXImageTransform.Microsoft.Matrix(sizingMethod=\‘auto expand\‘, M11=0.866025404, M12=0.5, M21=-0.5, M22=0.866025404);">‘ + watermarkText + ‘<br /><img  style="width:8em;" src="‘ + watermarkImg + ‘" /></div>‘);
                }
            }
        }
View Code

 

js添加水印(文字+图片水印效果)

原文:https://www.cnblogs.com/onesea/p/13553356.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!