_watermark.cshtml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. @{
  2. var u = ViewBag.UserRealName;
  3. var realName = ViewBag.UserRealName ?? ViewBag.UserName;
  4. var phone = !string.IsNullOrEmpty(ViewBag.UserWxPhone) ? ViewBag.UserWxPhone.Substring(ViewBag.UserWxPhone.Length - 4) : "";
  5. var text = realName + phone;
  6. }
  7. <style type="text/css" media="screen">
  8. .cover {
  9. position: absolute;
  10. left: 0;
  11. top: 0;
  12. z-index: 999999999999999;
  13. margin-right: 0px;
  14. margin-left: 0px;
  15. margin-top: 5px;
  16. margin-bottom: 140px;
  17. color: #fff;
  18. color: #ccc;
  19. display: block;
  20. padding: 2px 1px;
  21. font-family: '宋体';
  22. font-size: 16px;
  23. font-weight: bold;
  24. white-space: nowrap;
  25. text-shadow: 1px 0 0 #eee;
  26. transform: rotate(45deg);
  27. -ms-transform: rotate(45deg);
  28. -moz-transform: rotate(45deg);
  29. -webkit-transform: rotate(45deg);
  30. -o-transform: rotate(45deg);
  31. -moz-opacity: 0.3;
  32. opacity: 0.3;
  33. -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865474, M12=-0.7071067811865477, M21=0.7071067811865477, M22=0.7071067811865474, SizingMethod='auto expand')";
  34. }
  35. .cover-Blink-area {
  36. position: absolute;
  37. text-align: center;
  38. left: 0;
  39. top: 0;
  40. width: 100%;
  41. height: 100%;
  42. display: block;
  43. z-index: 999999999999999;
  44. pointer-events: none;
  45. overflow: hidden;
  46. }
  47. .cover-Blink {
  48. display: inline-block;
  49. margin-right: 50px;
  50. margin-left: 50px;
  51. margin-top: 50px;
  52. margin-bottom: 50px;
  53. color: red;
  54. padding: 2px 1px;
  55. font-size: 14px;
  56. color: #ccc;
  57. white-space: nowrap;
  58. transform: rotate(-20deg);
  59. -ms-transform: rotate(-20deg);
  60. -moz-transform: rotate(-20deg);
  61. -webkit-transform: rotate(-20deg);
  62. -o-transform: rotate(-20deg);
  63. opacity: 0.3;
  64. }
  65. </style>
  66. <script type="text/javascript">
  67. $(function () {
  68. waterMark$();
  69. });
  70. function waterMark$() {
  71. if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/11./i) != "11.") {
  72. $("p[name='p1$']").remove();
  73. var winwidth$ = document.body.scrollWidth - 17;
  74. var winheight$ = document.body.scrollHeight;
  75. $("body").append("<p id='waterSum_11' name='p1$' class='cover_through cover js-click-to-alert'>@text</p>");
  76. var fleft = Number($('#waterSum_11').css("margin-left").substring(0, $('#waterSum_11').css("margin-left").indexOf('p')));
  77. var ftop = Number($('#waterSum_11').css("margin-top").substring(0, $('#waterSum_11').css("margin-top").indexOf('p')));
  78. var perWidth = $("#waterSum_11").width();
  79. var perHeight = Number('140px'.substring(0, '140px'.indexOf('p'))) + 100;
  80. var lines = parseInt(winwidth$ / (perWidth + fleft));
  81. var rows = Math.round(winheight$ / (perHeight + ftop));
  82. var totalPWidth = perWidth * lines;
  83. var totalSpace = winwidth$ - totalPWidth;
  84. var perSpace = parseInt(totalSpace / (lines + 1));
  85. $('#waterSum_11').css("margin-left", perSpace);
  86. for (var i = 1; i <= rows; i++) {
  87. for (var j = 1; j <= lines; j++) {
  88. if (i == 1) {
  89. if (j <= lines - 1) {
  90. var p = "<p id='waterSum_" + i + "" + (j + 1) + "' name='p1$' class='cover_through cover js-click-to-alert'>@text</p>";
  91. var ileft = $('#waterSum_' + i + '' + j).css("margin-left").substring(0, $('#waterSum_' + i + '' + j).css("margin-left").indexOf('p'));
  92. var itop = $('#waterSum_11').css("margin-top").substring(0, $('#waterSum_11').css("margin-top").indexOf('p'));
  93. $("body").append(p);
  94. $('#waterSum_' + i + '' + (j + 1)).css("margin-left", Number(ileft) + Number(perWidth) + perSpace);
  95. $('#waterSum_' + i + '' + (j + 1)).css('margin-top', itop);
  96. }
  97. } else {
  98. var p = "<p id='waterSum_" + i + "" + j + "' name='p1$' class='cover_through cover js-click-to-alert'>${TmpContent}</p>";
  99. var ileft = $('#waterSum_' + (i - 1) + '' + j).css("margin-left").substring(0, $('#waterSum_' + (i - 1) + '' + j).css("margin-left").indexOf('p'));
  100. var itop = $('#waterSum_' + (i - 1) + '' + j).css("margin-top").substring(0, $('#waterSum_' + (i - 1) + '' + j).css("margin-top").indexOf('p'));
  101. $("body").append(p);
  102. $('#waterSum_' + i + '' + j).css("margin-left", Number(ileft));
  103. $('#waterSum_' + i + '' + j).css('margin-top', Number(itop) + Number(perHeight));
  104. }
  105. }
  106. }
  107. passThrough();
  108. } else {
  109. waterMarkNotIe$();
  110. }
  111. }
  112. function waterMarkNotIe$() {
  113. var winwidth$ = document.body.clientWidth;
  114. var winheight$ = document.body.scrollHeight;
  115. var waterSum$ = 100;
  116. var oldleft$ = 0;
  117. var maxI$ = 0;
  118. var k$ = 0;
  119. $("body").append("<div class='cover-Blink-area'> </div>");
  120. $('.cover-Blink-area').css('height', '500px');
  121. for (var i = 1; i <= waterSum$; i++) {
  122. $(".cover-Blink-area").append("<p id='waterSum_" + i + "' class='cover_through cover-Blink js-click-to-alert'>@text</p>");
  123. var left = Number(document.getElementById("waterSum_" + i).offsetLeft);
  124. if (left > oldleft$) {
  125. oldleft$ = left;
  126. maxI$ = i;
  127. }
  128. if (left < oldleft$ && k$ == 0) {
  129. var top = $("#waterSum_1").css("margin-top").substring(0, $("#waterSum_1").css("margin-top").indexOf('p'));
  130. var bottom = $("#waterSum_1").css("margin-bottom").substring(0, $("#waterSum_1").css("margin-bottom").indexOf('p'));
  131. var pHeight = $("#waterSum_1").height();
  132. var totalHeight = Number(top) + Number(pHeight) + Number(bottom);
  133. var Hnum = Math.round(500 / (totalHeight / 1.3));
  134. waterSum$ = Hnum * maxI$;
  135. k$++;
  136. }
  137. }
  138. }
  139. window.onresize = function () {
  140. waterMark$();
  141. }
  142. function passThrough() {
  143. $(".cover").mouseenter(function () {
  144. $(this).stop(true).fadeOut().delay(1500).fadeIn(50);
  145. });
  146. }
  147. </script>