Is it possible to apply CSS to half of a character?

后端 未结 19 1947
轻奢々
轻奢々 2020-11-22 16:46

What I am looking for:

A way to style one HALF of a character. (In this case, half the letter being transparent)

Wh

19条回答
  •  醉酒成梦
    2020-11-22 17:15

    Closest I can get:

    $(function(){
      $('span').width($('span').width()/2);
      $('span:nth-child(2)').css('text-indent', -$('span').width());
    });
    body{
      font-family: arial;
    }
    span{
      display: inline-block;
      overflow: hidden;
    }
    span:nth-child(2){
      color: red;
    }
    
    XX

    Demo: http://jsfiddle.net/9wxfY/2/

    Heres a version that just uses one span: http://jsfiddle.net/9wxfY/4/

提交回复
热议问题