Inner text shadow with CSS

后端 未结 22 1376
情深已故
情深已故 2020-11-28 18:07

I am currently playing around with CSS3 and trying to achieve a text effect like this (the black blurry inner shadow):

22条回答
  •  野性不改
    2020-11-28 18:28

    Here's a little trick I discovered using the :before and :after pseudo-elements:

    .depth {
        color: black;
        position: relative;
    }
    .depth:before, .depth:after {
        content: attr(title);
        color: rgba(255,255,255,.1);
        position: absolute;
    }
    .depth:before { top: 1px; left: 1px }
    .depth:after  { top: 2px; left: 2px }
    

    The title attribute needs to be the same as the content. Demo: http://dabblet.com/gist/1609945

提交回复
热议问题