Search code examples
htmlcsswatermark

Watermark text repeated diagonally css/html


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

enter image description here


Solution

  • Set the size of your container and float your text using absolute positioning while transforming your text with rotate.

    #watermark {
      height: 450px;
      width: 600px;
      position: relative;
      overflow: hidden;
    }
    #watermark img {
      max-width: 100%;
    }
    #watermark p {
      position: absolute;
      top: 0;
      left: 0;
      color: #fff;
      font-size: 18px;
      pointer-events: none;
      -webkit-transform: rotate(-45deg);
      -moz-transform: rotate(-45deg);
    }
    <div id="watermark">
      <img src="http://www.topchinatravel.com/pic/city/dalian/attraction/people-square-1.jpg">
      <p>This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark. This is a watermark.</p>
    </div>

    Note: For repeating text, I would suggest using either JavaScript or jQuery.