【发布时间】:2018-01-18 01:59:03
【问题描述】:
目标是模糊背景而不模糊其上方的所有其他元素。
背景和内容使用单独的div并依赖z-indexes的方法对我来说已经证明有点不灵活,所以我想知道是否可以在后台实现CSS模糊过滤器速记 语法(因为“background-filter: blur(5px)”不是有效的 CSS)只会将其应用于背景。
Tesla 用速记符号做得很好,但他们使用了透明/黑色渐变,而我想使用模糊。以下是我尝试过的一些基于 Tesla 登录页面的简化代码:
HTML:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="the-CSS-Written-Below">
</head>
<body class="background-image">
<div style="background-color: yellow">
<p>Some text that shouldn't be blurred!</p>
</div>
</body>
</html>
CSS:
.background-image{
background: radial-gradient(transparent, hsl(0, 0%, 2%)), gray url(http://leecamp.net/wp-content/uploads/kitten-3.jpg) no-repeat center center fixed;
}
这是JSFiddle,您可以看到它的样子。
然后,当我尝试将速记过滤器从径向渐变更改为模糊时,它停止工作:
CSS:
.background-image{
background: blur(5px), gray url(http://leecamp.net/wp-content/uploads/kitten-3.jpg) no-repeat center center fixed;
}
我不确定这里的模糊语法是否不正确/它需要不同的速记方式,或者这可能是完全错误的处理方式。甚至可以像这样简写模糊吗?
【问题讨论】:
标签: html css background blur shorthand