Inner text shadow with CSS

后端 未结 22 1340
情深已故
情深已故 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:45
    text-shadow: 4px 4px 2px rgba(150, 150, 150, 1);
    

    for box shadow:

    -webkit-box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75);
    -moz-box-shadow:    7px 7px 5px rgba(50, 50, 50, 0.75);
    box-shadow:         7px 7px 5px rgba(50, 50, 50, 0.75);
    

    you can see online text and box shadow: online text and box shadow

    for more example you can go to this address : more example code freeclup

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

    This is easily the best example I have seen. http://lab.simurai.com/carveme/

    The source is on gitthub https://github.com/simurai/lab/tree/gh-pages/carveme

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

    I've had a few instances where I've needed inner shadows on text, and the following has worked out well for me:

    .inner {
        color: rgba(252, 195, 67, 0.8);
        font-size: 48px;
        text-shadow: 1px 2px 3px #fff, 0 0 0 #000;
    }
    

    This sets the opacity of the text to 80%, and then creates two shadows:

    • The first is a white shadow (assuming the text is on a white background) offset 1px from the left and 2px from the top, blurred 3px.
    • The second is a black shadow which is visible through the 80% opacity text but not through the first shadow, which means it's visible inside the text letters only where the first shadow is displaced (1px from the left and 2px from the top). To change the blur of the this visible shadow, modify the blur parameter for the first layer shadow.

    Caveats

    • This will only work if the desired color of the text can be achieved without it having to be at 100% opacity.
    • This will only work if the background color is solid (so, it won't work for the questioner's specific example where the text sits on a textured background).
    0 讨论(0)
  • 2020-11-28 18:51

    Seems everyone's got an answer to this one. I like the solution from @Web_Designer. But it doesn't need to be as complex as that and you can still get the blurry inner shadow you're looking for.

    http://dabblet.com/gist/3877605

    .depth {
        display: block;
        padding: 50px;
        color: black;
        font: bold 7em Arial, sans-serif;
        position: relative;
     }
    
    .depth:before {
        content: attr(title);
        color: transparent;
        position: absolute;
        text-shadow: 2px 2px 4px rgba(255,255,255,0.3);
    }
    
    0 讨论(0)
提交回复
热议问题