原标题:比较好用的 CSS 的技巧,总有一个你需要的!
一、黑白图像
当你需要让一张彩色的图片显示为黑白照片的时候,你可以用下面的一段代码。
二、使用 :not() 在菜单上应用/取消应用边框
三、页面顶部阴影
给网页加上漂亮的顶部阴影效果
四、给 body 添加行高
不需要给别给 p,h之类的添加行高,直接:
body{ line-height: 1;}
五、所有一切都垂直居中
IE11中需要注意 flexbox
六、逗号分隔列表
让HTML列表项看上去像被一个真正的,分隔的列表
ul > li:not(:last-child)::after{ content: ","; }
七、使用负的 nth-child 选择项目
在 css 中使用负的 nth-child 选择项目1到项目n
八、对图标使用 SVG
.logo{ background: url("logo.svg"); }
九、优化显示文本
有时候,字体并不能在所有设备上都达到最佳的显示,所以可以让设备浏览器来帮助你
十、对纯 css 滑块使用 max-height
使用 max-height 和溢出隐藏来实现只有 css 的滑块
责任编辑: