CSS After Element to insert mailto link?

后端 未结 5 1487
臣服心动
臣服心动 2020-12-03 22:05

I\'m attempting to display a mailto link. Is that possible with CSS?

html

  • <
    5条回答
    •  悲哀的现实
      2020-12-03 22:41

      Content added with the pseudo-element doesn't appear in the DOM, so no you can't. But why do you want to do it with CSS ? It is not styling, the right place seems to be directly on the HTML file.

      If the goal is to block spam, I usually use this piece of javascript:

      var m; 
      m='in';
      m+='f';
      m+='o@exa';
      m+='mpl';
      m+='e.co';
      m+='m';
      $ele = document.getElementById('contact-mail');
      $ele.href = 'mailto:'+m;
      $ele.innerHTML = m;
      

      The mail is splitted to be sure that it doesn't appear as an email in any file.

      You can see the result here: http://jsfiddle.net/tzkDt/ ​

    提交回复
    热议问题