Hide text, but have it show up if copied and pasted without javascript

后端 未结 2 829
南笙
南笙 2021-01-15 12:54

I\'m trying to do a design for a short story site.
One of the stories I\'ve been told would work better if someone copied and pasted text, extra lines would show up.

2条回答
  •  忘掉有多难
    2021-01-15 13:40

    This is a possible solution to this problem, however it may or may not be appropriate.

    Only appears after pasting

    Potentially if you want it to only appear in the pasted text (rather than when it's highlighted) you could make the font both tiny and transparent so it can be hidden between the other text e.g.

    div {
      color: #000;
      background-color: #FFF;
    }
    
    .hidden{
      /* Transparent text, should work on any background colour */
      color: rgba(0,0,0,0); 
      font-size: 0;
    }
    This is visible. (Copy and paste this to see the hidden line)

    Visible while selected

    If you would prefer the text to be visible simply by selecting it, you can either match the background colour set it to a transparent colour.

    div {
      color: #000;
      background-color: #FFF;
    }
    
    .hidden1{
      /* Match the background colour */
      color: #FFF;
    }
    
    .hidden2{
      /* Transparent text, should work on any background colour */
      color: rgba(0,0,0,0); 
    }
    This is visible. This is not. Nor is this.

提交回复
热议问题