CSS3实现网页平滑过渡效果
代码部分:
|
|
|
|
技术点
- 通过
input
的checked
单选按钮实现是否被选中 - translate3d(可以开启GPU硬件加速)
- CSS3画三角形
- backface-visibility
- transition
- @font-face实现小icon(不用切图,减少http请求)
- animation
- @keyframes
- 自适应(响应式 用媒体查询实现)
- @media query
-webkit-font-smoothing 字体平滑处理和抗锯齿渲染
CSS3里面加入了一个“-webkit-font-smoothing”
属性。
这个属性可以使页面上的字体抗锯齿,使用后字体看起来会更清晰舒服。
它有三个属性:
none
—— 对低像素的文本比较好subpixel-antialiased
——默认值antialiased
——抗锯齿很好
例子:
|
|
国外某网站例子
附:
|
|
这个属性也是更清晰的作用,特别是图标文字流行的今天。
隐藏元素的四种方法
dispaly:none;
//隐藏不占位
|
|
|
|
|
|
PS:
这个demo里导航的移动原理是css的transitionY,而非一般导航里的通过标签a去链接;
而position:fixde这个定位机制让a标签本身的链接作用作废了(大家可以试试,反正一旦给链接设置成fixed链接作用就失效),链接作用作废的话a的visited状态就失效了,所以这里才选择了input去表达状态的选中与否(因为不同于hover状态是所有盒子都具备的,visited(or checked)状态只有a标签和input的radio type有);
以上,详细解释了为什么用input,最后强调一下,这里的a标签只起到一个语义化的作用。
css3生成三角形看我的这篇博文 点这里
Browser and device support
Internet Explorer 8 and @font-face
- IE8 has some issues with @font-face when combined with :before. Bootstrap uses that combination with its Glyphicons. If a page is cached, and loaded without the mouse over the window (i.e. hit the refresh button or load something in an iframe) then the page gets rendered before the font loads. Hovering over the page (body) will show some of the icons and hovering over the remaining icons will show those as well. See issue #13863 for details.
IE Compatibility modes
- CSS3 is not supported in the old Internet Explorer compatibility modes. To be sure you’re using the latest rendering mode for IE, consider including the appropriate tag in your pages:
|
|
Confirm the document mode by opening the debugging tools: press F12 and check the “Document Mode”.
This tag is included in all of Bootstrap’s documentation and examples to ensure the best rendering possible in each supported version of Internet Explorer.
See this StackOverflow question for more information.
|
|
参考
慕课网 css3实现网页平滑过渡效果
Browser and device support
http://www.dafont.com/
http://www.google.com/webfonts
@font-face
CSS-Only Responsive Layout with Smooth Transitions