Inner text shadow with CSS

后端 未结 22 1338
情深已故
情深已故 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:25

    You should be able to do it using the text-shadow, erm somethink like this:

    .inner_text_shadow
    {
        text-shadow: 1px 1px white, -1px -1px #444;
    }
    

    here's an example: http://jsfiddle.net/ekDNq/

    0 讨论(0)
  • 2020-11-28 18:27

    Try this little gem of a variation:

    text-shadow:0 1px 1px rgba(255, 255, 255, 0.5);
    

    I usually take "there's no answer" as a challenge

    0 讨论(0)
  • 2020-11-28 18:27

    Try this example for inset text shadow. Here's the HTML

    <h1 class="inset-text-shadow">Inset text shadow trick</h1>
    

    and the CSS

    body {
        background: #f8f8f8;
    }
    h1 {
        font-family: Helvetica, Arial, sans-serif;
        font-weight: bold;
        font-size: 6em;
        line-height: 1em;
    }
    .inset-text-shadow {
        /* Shadows are visible under slightly transparent text color */
        color: rgba(0,0,0,0.6);
        text-shadow: 2px 8px 6px rgba(0,0,0,0.2), 0px -5px 35px rgba(255,255,255,0.3);
    
    }
    

    Demo on Jsfiddle

    0 讨论(0)
  • 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

    0 讨论(0)
  • 2020-11-28 18:29

    There's a much simpler way to achieve this

    .inner{color: red; text-shadow: 0 -1px 0 #666;} // #666 is the color of the inner shadow
    

    Voilà

    0 讨论(0)
  • 2020-11-28 18:29

    I'm using it from this site, also it looks good. Have a look at it Inner shadow

    0 讨论(0)
提交回复
热议问题