Watermark text repeated diagonally css/html

Captain Obvious picture Captain Obvious · Nov 28, 2016 · Viewed 35.6k times · Source

How can I achieve the following watermark text ("howbloggerz") with css/html?

enter image description here

Answer

Gerrit0 picture Gerrit0 · Nov 28, 2016

This is pretty similar to Daerik's answer, but I wanted to avoid using an extra element, and automate the watermark text generation.

Array.from(document.querySelectorAll('.watermarked')).forEach(function(el) {
  el.dataset.watermark = (el.dataset.watermark + ' ').repeat(300);
});
.watermarked {
  position: relative;
  overflow: hidden;
}

.watermarked img {
  width: 100%;
}

.watermarked::before {
  position: absolute;
  top: -75%;
  left: -75%;
  
  display: block;
  width: 150%;
  height: 150%;
  
  transform: rotate(-45deg);
  content: attr(data-watermark);
  
  opacity: 0.7;
  line-height: 3em;
  letter-spacing: 2px;
  color: #fff;
}
<div class="watermarked" data-watermark="howbloggerz">
  <img src="http://www.w3schools.com/css/img_fjords.jpg">
</div>