带有 CSS 的内部文本阴影 [英] Inner text shadow with CSS

查看:24
本文介绍了带有 CSS 的内部文本阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 CSS3 并尝试实现这样的文本效果(黑色模糊的内阴影):

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

但我找不到在文本内创建文本阴影的方法.我想知道是否还有可能,因为 box-shadow 元素能够像这样在内部渲染阴影:

But I cannot find a way to create text shadows inside the text. I wonder whether it is still possible because the box-shadow element is able to render shadow inside like this:

box-shadow: inset 0px -5px 10px 0px rgba(0, 0, 0, 0.5);

有什么想法吗?

推荐答案

这是我在使用 :before:after 伪元素时发现的一个小技巧:

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 }

title 属性需要和内容一致.演示:http://dabblet.com/gist/1609945

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

这篇关于带有 CSS 的内部文本阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆