这个类型的滤镜只是改变了下图像的原来样子而已,保存或导出图像时并没有用所说的滤镜,但当你需要给照片美化或处理海报时这很好用。 Pointr Events和 Bricking Clicks CSS的Pointr Events属性提供了一个方法来有效的禁用一个元素,正因为如此,通过JavaScript,点击一个链接不会触发一个单击事件: 复制代码 代码如下: /* do nothing when clicked or activated */ .disabled { pointer-events: none; }/* this will _not_ fire because of the pointer-events: none application */ document.getElementById("disabled-element").addEventListener("click", function(e) { alert("Clicked!"); });
折叠、展开菜单 CSS让我们可以创建过渡效果和动画,但是很多时候我们需要JavaScript库来帮助我们修改一些东西和控制动画。一个很流行的动画就是折叠、展开菜单效果,很多人都不知道只用CSS就可以实现! 复制代码 代码如下: /* slider in open state */ .slider { overflow-y: hidden; max-height: 500px; /* approximate max height */ transition-property: all; transition-duration: .5s; transition-timing-function: cubic-bezier(0, 1, 0.5, 1); } /* close it with the "closed" class */ .slider.closed { max-height: 0; }
Max-height的一个巧妙使用能让元素按想要的效果来折叠和展开。 CSS计数器 “计数器”这个术语在网络上表示的意思经常让我们傻笑,但CSS 计数器是另一件更让我们傻笑的事。CSS计数器允许开发人员在指定的元素上用:before和:after来增加一个计数器: 复制代码 代码如下: /* initialize the counter */ ol.slides { counter-reset: slideNum; } /* increment the counter */ ol.slides > li { counter-increment: slideNum; } /* display the counter value */ ol.slides li:after { content: "[" counter(slideNum) "]"; }
请别用这些符号。除非你能行! CSS圆 CSS三角形是一个技术活,CSS圆也同样如此。通过滥用CSS border-radius,你能创建很完美的圆! 复制代码 代码如下: circle { border-radius: 50%; width: 200px; height: 200px; /* width and height can be anything, as long as they"re equal */ }