【发布时间】:2019-02-04 03:41:42
【问题描述】:
我正在尝试开发一个使用 CSS 铅笔效果过滤器的应用。
我复制的代码似乎与我从中获取它的页面上的代码不同。在我的开发环境中,它只是将图像转换为灰度,并没有实现铅笔效果。
为什么这段代码不能在我的开发环境中运行?
我的代码:
<html>
<style>
div {
overflow: hidden;
background-image: url('https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTuYvJOVHBvDlrc_9N2QdTwltioVq1og5UkLsLo1-32kFcxhmZyYQ');
width: 170px;
height: 200px;
overflow: hidden;
position: relative;
filter: grayscale(100%);
&:after {
content: '';
background: inherit;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
filter: grayscale(100%) invert(100%) blur(5px);
mix-blend-mode: color-dodge;
}
}
</style>
<body>
<div role="img"></div>
</body>
</html>
div {
overflow: hidden;
background-image: url('https://cdn-images-1.medium.com/max/1600/1*v-q4is6XGAQ6XLYI2m7NzQ.jpeg');
width: 160px;
height: 196px;
overflow: hidden;
position: relative;
filter: grayscale(100%);
&:after {
content: '';
background: inherit;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
filter: grayscale(100%) invert(100%) blur(5px);
mix-blend-mode: color-dodge;
}
}
【问题讨论】:
-
那么这个“不工作”是怎么回事。
-
你需要向我们展示它应该如何工作
标签: html css image filter sass