demo.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <html>
  2. <head>
  3. <meta charset="utf-8"/>
  4. <title>Webfont Demo</title>
  5. <style>
  6. /*
  7. KISSY CSS Reset
  8. 理念:1. reset 的目的不是清除浏览器的默认样式,这仅是部分工作。清除和重置是紧密不可分的。
  9. 2. reset 的目的不是让默认样式在所有浏览器下一致,而是减少默认样式有可能带来的问题。
  10. 3. reset 期望提供一套普适通用的基础样式。但没有银弹,推荐根据具体需求,裁剪和修改后再使用。
  11. 特色:1. 适应中文;2. 基于最新主流浏览器。
  12. 维护:玉伯<lifesinger@gmail.com>, 正淳<ragecarrier@gmail.com>
  13. */
  14. /** 清除内外边距 **/
  15. body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, /* structural elements 结构元素 */
  16. dl, dt, dd, ul, ol, li, /* list elements 列表元素 */
  17. pre, /* text formatting elements 文本格式元素 */
  18. form, fieldset, legend, button, input, textarea, /* form elements 表单元素 */
  19. th, td /* table elements 表格元素 */ {
  20. margin: 0;
  21. padding: 0;
  22. }
  23. /** 设置默认字体 **/
  24. body,
  25. button, input, select, textarea /* for ie */ {
  26. font: 12px/1.5 tahoma, arial, \5b8b\4f53, sans-serif;
  27. }
  28. h1, h2, h3, h4, h5, h6 { font-size: 100%; }
  29. address, cite, dfn, em, var { font-style: normal; } /* 将斜体扶正 */
  30. code, kbd, pre, samp { font-family: courier new, courier, monospace; } /* 统一等宽字体 */
  31. small { font-size: 12px; } /* 小于 12px 的中文很难阅读,让 small 正常化 */
  32. /** 重置列表元素 **/
  33. ul, ol { list-style: none; }
  34. /** 重置文本格式元素 **/
  35. a { text-decoration: none; }
  36. a:hover { text-decoration: underline; }
  37. /** 重置表单元素 **/
  38. legend { color: #000; } /* for ie6 */
  39. fieldset, img { border: 0; } /* img 搭车:让链接里的 img 无边框 */
  40. button, input, select, textarea { font-size: 100%; } /* 使得表单元素在 ie 下能继承字体大小 */
  41. /* 注:optgroup 无法扶正 */
  42. /** 重置表格元素 **/
  43. table { border-collapse: collapse; border-spacing: 0; }
  44. /* 清除浮动 */
  45. .ks-clear:after, .clear:after {
  46. content: '\20';
  47. display: block;
  48. height: 0;
  49. clear: both;
  50. }
  51. .ks-clear, .clear {
  52. *zoom: 1;
  53. }
  54. .main {padding: 30px 100px;}
  55. .main h1{font-size:36px; color:#333; text-align:left;margin-bottom:30px; border-bottom: 1px solid #eee;}
  56. .helps{margin-top:40px;}
  57. .helps pre{
  58. padding:20px;
  59. margin:10px 0;
  60. border:solid 1px #e7e1cd;
  61. background-color: #fffdef;
  62. overflow: auto;
  63. }
  64. .icon_lists li{
  65. float:left;
  66. width: 100px;
  67. height:150px;
  68. text-align: center;
  69. }
  70. .icon_lists .icon{
  71. font-size: 42px;
  72. line-height: 100px;
  73. margin: 10px 0;
  74. color:#333;
  75. -webkit-transition: font-size 0.25s ease-out 0s;
  76. -moz-transition: font-size 0.25s ease-out 0s;
  77. transition: font-size 0.25s ease-out 0s;
  78. }
  79. .icon_lists .icon:hover{
  80. font-size: 100px;
  81. }
  82. @font-face {
  83. font-family: "webfont";
  84. font-display: swap;
  85. src: url('webfont.eot'); /* IE9 */
  86. src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
  87. url('webfont.woff2') format('woff2'),
  88. url('webfont.woff') format('woff'), /* chrome、firefox */
  89. url('webfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/
  90. url('webfont.svg#webfont') format('svg'); /* iOS 4.1- */
  91. }
  92. .web-font {
  93. font-family: "webfont" !important;
  94. font-size: 16px;
  95. font-style: normal;
  96. -webkit-font-smoothing: antialiased;
  97. -moz-osx-font-smoothing: grayscale;
  98. }
  99. </style>
  100. </head>
  101. <body>
  102. <div class="main">
  103. <h1>webfont 字体预览</h1>
  104. <p class="web-font">琴棋书画不会,洗衣做饭嫌累</p>
  105. <div class="helps">
  106. 第一步:使用font-face声明字体
  107. <pre>
  108. @font-face {
  109. font-family: 'webfont';
  110. font-display: swap;
  111. src: url('webfont.eot'); /* IE9 */
  112. src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
  113. url('webfont.woff2') format('woff2'),
  114. url('webfont.woff') format('woff'), /* chrome、firefox */
  115. url('webfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/
  116. url('webfont.svg#webfont') format('svg'); /* iOS 4.1- */
  117. }
  118. </pre>
  119. 第二步:定义使用 webfont 的样式
  120. <pre>
  121. .web-font {
  122. font-family: "webfont" !important;
  123. font-size: 16px;
  124. font-style: normal;
  125. -webkit-font-smoothing: antialiased;
  126. -moz-osx-font-smoothing: grayscale;
  127. }
  128. </pre>
  129. 第三步:为文字加上对应的样式
  130. <pre>
  131. &lt;i class="web-font"&gt;琴棋书画不会,洗衣做饭嫌累&lt;/i&gt;
  132. </pre>
  133. </div>
  134. </div>
  135. </body>
  136. </html>