nukl
nukl

Reputation: 10521

CSS3 filters as a mask

It's possible to use css3 filters as a mask? For instance, i want to blur only 30% of a div from the top. How can i do it?

I create a little jsfiddle to illustrate what i'm trying to achive: http://jsfiddle.net/uxCXa/2/

Upvotes: 4

Views: 840

Answers (1)

pzin
pzin

Reputation: 4248

I would use a pseudo-element to achieve that and adding a box-shadow to fake WebKit's blur filter.

.container {
  position: relative;
  width: 200px;
}

.container:after {
  position: absolute;
  top: 15%;
  bottom: 15%;
  left: 0;
  right: 0;
  background: rgba(100,100,100,0.3);
  box-shadow: 0 0 3px 0 rgba(100,100,100,0.3);
  z-index: 2;
  content: "";
}

top and bottom need to be the half of that 30% you want.

Upvotes: 2

Related Questions