毛玻璃
by 苹果熊
HTML
<div class="bg">
<div class="inner"><p>template & JSX。众所周知,Vue 1.0使用的是template来实现模板,而React使用了JSX实现模板。关于template和JSX的争论也很多,很多人不使用React就是因为没有支持template写法。Vue 2.0对template和JSX写法都做了支持。使用时,可以根据具体业务细节进行选择,可以很好的发挥两者的优势。就这一点,Vue已经超过React了。Server Render。2.0还对了Server Render做了支持。这一点并没有在业务中使用,不做评价。</p></div>
</div>
CSS
.bg, .inner::before {
background: url(http://a4.topitme.com/o072/100727679316e68d00.jpg) 0 / cover fixed;
}
.bg {
position: relative;
width: 100vw;
height: 100vh;
z-index: 1;
}
.inner {
width: 100%;
height: 100%;
color: #333;
background: hsla(0, 0%, 100%, .1);
color: #fff;
position: relative;
overflow: hidden;
}
.inner::before {
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
border-radius: inherit;
filter: blur(10px);
margin: -30px;
z-index: -1;
transition: filter .2s;
}
.inner.on::before {
filter: none;
}
JavaScript
var inner = document.querySelector('.inner');
inner.onclick = function() {
this.classList.toggle('on')
}