技术控

    今日:53| 主题:49507
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Having Fun With Tomorrow’s CSS: Backdrop Filters

[复制链接]
可爱情人〆、 发表于 2016-10-6 00:13:24
285 3

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
In this tutorial we will look into an emerging CSS toy going by the name of Backdrop Filter .
   The backdrop-filter proposal is heavily influenced by the Apple design language, particularly that frosty-transparent-blurry-background seen in their most recent iOS and macOS interfaces. You’ll have noticed it in the Dock,the Contextual Menu, and the Notification centre.
     
Having Fun With Tomorrow’s CSS: Backdrop Filters-1 (currently,property,familiar,included,noticed)
     Backdrop filter is currently baked under CSS Filters Level 2, and at the time of the writing, it only works work in Safari 9 with the  -webkit- prefix, and Chrome as well as Opera by enabling the “Experimental Web Platform Features” under the  chrome://flags menu.

Having Fun With Tomorrow’s CSS: Backdrop Filters-2 (currently,property,familiar,included,noticed)
    Using Backdrop Filter

   Backdrop-filter is included as part of the CSS Filters specification and thus, similarly to the filter property, it inherits all the familiar filtering functions such  grayscale() ,  blur() , and  sepia() . The only difference here is that it will affect the elements underneath the selected element.
  To use it, we will need at least two elements; the first element will be the target, while the second will lie underneath it. For example:
  [code]

Having Fun With Tomorrow’s CSS: Backdrop Filters-3 (currently,property,familiar,included,noticed)[/code]   Set a background in the first element with low opacity so we can add backdrop-filter with a function, for example,  grayscale() to turn the backdrop black and white.
  [code].filter {
    -webkit-backdrop-filter: blur(10px); /* Safari 9+ */
    backdrop-filter: blur(10px); /* Chrome and Opera */
    background-color: rgba(255, 255, 255, 0.3);
}[/code]   Notice in the following demo that descendants of the .filter elements (a button in this case) remain crisp despite the  blur() function addition. This is an advantage  backdrop-filter has over the  filter property; where all descendants are impacted.
   Note: image here taken from tutorial  How to Create a Little Red Riding Hood Inspired Fairytale Illustration in Paint Tool SAI .
  Combining Multiple Filters

   Combining two filter functions in a single declaration is also acceptable. For example, keeping our blur() , but adding the  grayscale() function to strip the backdrop of color.
  [code].filter {
    -webkit-backdrop-filter: grayscale() blur(10px); /* Safari 9+ */
    backdrop-filter: grayscale() blur(10px); /* Chrome and Opera */
    background-color: rgba(255, 255, 255, 0.3);
}[/code]  Other functions you can add into the mix include:
  
       
  • brightness() : accepting a number from 0 to infinity, or percentage. Any number below  1 , e.g.  0.8 , will darken the element, and specifying any number above  1  will lighten the element.   
  • contrast() : accepts a number and percentage which works similar to the  brightness()  function, except this function defines the element contrast.   
  • invert() : this function generates the opposite or negative colors of the backdrop. Likewise, the function also accepts a number and percentage as the value.  
  Advanced Filter With SVG

   If you can’t find the desired effect from these default functions, you can always add a more advanced filter through SVG. Create an SVG filter with a unique ID, and save it in an .svg file:
  [code]

[/code]   Refer the filter with the url() function, like so.
  [code].filter {
    -webkit-backdrop-filter: url(../images/filter.svg#morph); /* Safari 9 */
    backdrop-filter: url(../images/filter.svg#morph); /* Chrome and Opera */
}[/code]   Unfortunately, adding filter with the url() function does not seem to work in any browser at the persent time. But once properly implemented, the image should look like this.
123下一页
友荐云推荐




上一篇:如何用一行命令让 Systemd 崩溃
下一篇:Tutorial: Java and Maven in Eclipse Che
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

道听途说 发表于 2016-10-6 10:09:13
来,来,干了这杯翔!
回复 支持 反对

使用道具 举报

bw344 发表于 2016-10-7 02:40:09
走,MM,咱们化蝶去……  
回复 支持 反对

使用道具 举报

zyxin 发表于 2016-10-8 07:51:55
冷艳高贵接地气
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表