`

HTML Typo.css 中文网页重设与排版

阅读更多

typo.css

@charset "utf-8";

/* 防止用户自定义背景颜色对网页的影响,添加让用户可以自定义字体 */
html {
  color: #333;
  background: #fff;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-rendering: optimizelegibility;
}

/* 如果你的项目仅支持 IE9+ | Chrome | Firefox 等,推荐在 <html> 中添加 .borderbox 这个 class */
html.borderbox *, html.borderbox *:before, html.borderbox *:after {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

/* 内外边距通常让各个浏览器样式的表现位置不同 */
body, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, textarea, p, blockquote, th, td, hr, button, article, aside, details, figcaption, figure, footer, header, menu, nav, section {
  margin: 0;
  padding: 0;
}

/* 重设 HTML5 标签, IE 需要在 js 中 createElement(TAG) */
article, aside, details, figcaption, figure, footer, header, menu, nav, section {
  display: block;
}

/* HTML5 媒体文件跟 img 保持一致 */
audio, canvas, video {
  display: inline-block;
}

/* 要注意表单元素并不继承父级 font 的问题 */
body, button, input, select, textarea {
  font: 300 1em/1.8 PingFang SC, Lantinghei SC, Microsoft Yahei, Hiragino Sans GB, Microsoft Sans Serif, WenQuanYi Micro Hei, sans;
}

button::-moz-focus-inner,
input::-moz-focus-inner {
  padding: 0;
  border: 0;
}

/* 去掉各Table cell 的边距并让其边重合 */
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* 去除默认边框 */
fieldset, img {
  border: 0;
}

/* 块/段落引用 */
blockquote {
  position: relative;
  color: #999;
  font-weight: 400;
  border-left: 1px solid #1abc9c;
  padding-left: 1em;
  margin: 1em 3em 1em 2em;
}

@media only screen and ( max-width: 640px ) {
  blockquote {
    margin: 1em 0;
  }
}

/* Firefox 以外,元素没有下划线,需添加 */
acronym, abbr {
  border-bottom: 1px dotted;
  font-variant: normal;
}

/* 添加鼠标问号,进一步确保应用的语义是正确的(要知道,交互他们也有洁癖,如果你不去掉,那得多花点口舌) */
abbr {
  cursor: help;
}

/* 一致的 del 样式 */
del {
  text-decoration: line-through;
}

address, caption, cite, code, dfn, em, th, var {
  font-style: normal;
  font-weight: 400;
}

/* 去掉列表前的标识, li 会继承,大部分网站通常用列表来很多内容,所以应该当去 */
ul, ol {
  list-style: none;
}

/* 对齐是排版最重要的因素, 别让什么都居中 */
caption, th {
  text-align: left;
}

q:before, q:after {
  content: '';
}

/* 统一上标和下标 */
sub, sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
}

:root sub, :root sup {
  vertical-align: baseline; /* for ie9 and other modern browsers */
}

sup {
  top: -0.5em;
}

sub {
  bottom: -0.25em;
}

/* 让链接在 hover 状态下显示下划线 */
a {
  color: #1abc9c;
}

a:hover {
  text-decoration: underline;
}

.typo a {
  border-bottom: 1px solid #1abc9c;
}

.typo a:hover {
  border-bottom-color: #555;
  color: #555;
  text-decoration: none;
}

/* 默认不显示下划线,保持页面简洁 */
ins, a {
  text-decoration: none;
}

/* 专名号:虽然 u 已经重回 html5 Draft,但在所有浏览器中都是可以使用的,
 * 要做到更好,向后兼容的话,添加 class="typo-u" 来显示专名号
 * 关于 <u> 标签:http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-u-element
 * 被放弃的是 4,之前一直搞错 http://www.w3.org/TR/html401/appendix/changes.html#idx-deprecated
 * 一篇关于 <u> 标签的很好文章:http://html5doctor.com/u-element/
 */
u, .typo-u {
  text-decoration: underline;
}

/* 标记,类似于手写的荧光笔的作用 */
mark {
  background: #fffdd1;
  border-bottom: 1px solid #ffedce;
  padding: 2px;
  margin: 0 5px;
}

/* 代码片断 */
pre, code, pre tt {
  font-family: Courier, 'Courier New', monospace;
}

pre {
  background: #f8f8f8;
  border: 1px solid #ddd;
  padding: 1em 1.5em;
  display: block;
  -webkit-overflow-scrolling: touch;
}

/* 一致化 horizontal rule */
hr {
  border: none;
  border-bottom: 1px solid #cfcfcf;
  margin-bottom: 0.8em;
  height: 10px;
}

/* 底部印刷体、版本等标记 */
small, .typo-small,
  /* 图片说明 */
figcaption {
  font-size: 0.9em;
  color: #888;
}

strong, b {
  font-weight: bold;
  color: #000;
}

/* 可拖动文件添加拖动手势 */
[draggable] {
  cursor: move;
}

.clearfix:before, .clearfix:after {
  content: "";
  display: table;
}

.clearfix:after {
  clear: both;
}

.clearfix {
  zoom: 1;
}

/* 强制文本换行 */
.textwrap, .textwrap td, .textwrap th {
  word-wrap: break-word;
  word-break: break-all;
}

.textwrap-table {
  table-layout: fixed;
}

/* 提供 serif 版本的字体设置: iOS 下中文自动 fallback 到 sans-serif */
.serif {
  font-family: Palatino, Optima, Georgia, serif;
}

/* 保证块/段落之间的空白隔行 */
.typo p, .typo pre, .typo ul, .typo ol, .typo dl, .typo form, .typo hr, .typo table,
.typo-p, .typo-pre, .typo-ul, .typo-ol, .typo-dl, .typo-form, .typo-hr, .typo-table, blockquote {
  margin-bottom: 1.2em
}

h1, h2, h3, h4, h5, h6 {
  font-family: PingFang SC, Verdana, Helvetica Neue, Microsoft Yahei, Hiragino Sans GB, Microsoft Sans Serif, WenQuanYi Micro Hei, sans-serif;
  font-weight: 100;
  color: #000;
  line-height: 1.35;
}

/* 标题应该更贴紧内容,并与其他块区分,margin 值要相应做优化 */
.typo h1, .typo h2, .typo h3, .typo h4, .typo h5, .typo h6,
.typo-h1, .typo-h2, .typo-h3, .typo-h4, .typo-h5, .typo-h6 {
  margin-top: 1.2em;
  margin-bottom: 0.6em;
  line-height: 1.35;
}

.typo h1, .typo-h1 {
  font-size: 2em;
}

.typo h2, .typo-h2 {
  font-size: 1.8em;
}

.typo h3, .typo-h3 {
  font-size: 1.6em;
}

.typo h4, .typo-h4 {
  font-size: 1.4em;
}

.typo h5, .typo h6, .typo-h5, .typo-h6 {
  font-size: 1.2em;
}

/* 在文章中,应该还原 ul 和 ol 的样式 */
.typo ul, .typo-ul {
  margin-left: 1.3em;
  list-style: disc;
}

.typo ol, .typo-ol {
  list-style: decimal;
  margin-left: 1.9em;
}

.typo li ul, .typo li ol, .typo-ul ul, .typo-ul ol, .typo-ol ul, .typo-ol ol {
  margin-bottom: 0.8em;
  margin-left: 2em;
}

.typo li ul, .typo-ul ul, .typo-ol ul {
  list-style: circle;
}

/* 同 ul/ol,在文章中应用 table 基本格式 */
.typo table th, .typo table td, .typo-table th, .typo-table td, .typo table caption {
  border: 1px solid #ddd;
  padding: 0.5em 1em;
  color: #666;
}

.typo table th, .typo-table th {
  background: #fbfbfb;
}

.typo table thead th, .typo-table thead th {
  background: #f1f1f1;
}

.typo table caption {
  border-bottom: none;
}

/* 去除 webkit 中 input 和 textarea 的默认样式  */
.typo-input, .typo-textarea {
  -webkit-appearance: none;
  border-radius: 0;
}

.typo-em, .typo em, legend, caption {
  color: #000;
  font-weight: inherit;
}

/* 着重号,只能在少量(少于100个字符)且全是全角字符的情况下使用 */
.typo-em {
  position: relative;
}

.typo-em:after {
  position: absolute;
  top: 0.65em;
  left: 0;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  content: "・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・";
}

/* Responsive images */
.typo img {
  max-width: 100%;
}

 

typo.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"/>
  <meta name="description" content="Typo.css 的目的是,在一致化浏览器排版效果的同时,构建最适合中文阅读的网页排版。作者:sofish Lin,基于 MIT License 协议开源。"/>
  <meta name="viewport" content="width=device-width, minimal-ui">
  <link rel="stylesheet" href="./typo.css"/>
  <title>Typo.css - 中文网页重设与排版</title>
  <style>
    code{ color:#1abc9c; }
    html{ background:#eee; }
    body{ width:90%; max-width: 960px; background:#fff; margin:3em auto 0; padding-top:2em;border:1px solid #ddd;border-width:0 1px;}
    pre{white-space:pre-wrap;}

    i.serif{ text-transform:lowercase; color:#1abc9c; }
    :-moz-any(h1, h2, h3, h4, h5, h5) i.serif{ text-transform: capitalize; }
    i.serif:hover{ color:inherit; }

    #wrapper{ padding:5% 10%; position:relative;}
    #tagline{ color:#999; font-size:1em; margin:-2em 0 2em; padding-bottom:2em; border-bottom:3px double #eee; }
    #fork{ position:fixed; top:0; right:0; _position:absolute; }
    #table{ margin-bottom:2em; color:#888; }
    #github{ position:absolute;top:1em;}
    #github iframe{ display:inline;margin-right:1em; }

    @media only screen and (max-width: 640px) {
      table{ word-break:break-all;word-wrap:break-word;font-size:12px; }
      .typo table th, .typo table td, .typo-table th, .typo-table td .typo table caption {
        padding: 0.5em;
      }
      #fork{ display:none; }
    }
  </style>
</head>
<body>

<div id="github">
  <iframe src="http://ghbtns.com/github-btn.html?user=sofish&repo=typo.css&type=watch&count=true"
          allowtransparency="true" frameborder="0" scrolling="0" width="98" height="20"></iframe>
  <iframe src="http://ghbtns.com/github-btn.html?user=sofish&type=follow&count=true"
          allowtransparency="true" frameborder="0" scrolling="0" width="156" height="20"></iframe>
</div>

<div id="wrapper" class="typo typo-selection">

<h1>中文网页重设与排版:<i class="serif">Typo.css</i></h1><br/>

<h2 id="tagline" class="serif">一致化浏览器排版效果,构建最适合中文阅读的网页排版</h2>

<ol id="table">
  <li><a href="#section1">关于 <i class="serif">Typo.css</i></a></li>
  <li><a href="#section2">排版实例</a>
    <ul>
      <li><a href="#section2-1">例1:论语学而篇第一</a></li>
      <li><a href="#section2-2">例2:英文排版</a></li>
    </ul>
  </li>
  <li><a href="#section3">附录</a>
    <ul>
      <li><a href="#appendix1"><i class="serif">Typo.css</i> 排版偏重点</a></li>
      <li><a href="#appendix2">开源许可</a></li>
    </ul>
  </li>
</ol>

<h2 id="section1">一、关于 <i class="serif">Typo.css</i></h2>

<p><i class="serif">Typo.css</i> 的目的是,在一致化浏览器排版效果的同时,构建最适合中文阅读的网页排版。</p>
<h4>现状和如何去做:</h4>

<p class="typo-first">排版是一个麻烦的问题 <sup><a href="#appendix1"># 附录一</a></sup>,需要精心设计,而这个设计却是常被视觉设计师所忽略的。前端工程师更常看到这样的问题,但不便变更。因为在多个 OS 中的不同浏览器渲染不同,改动需要多的时间做回归测试,所以改变变得更困难。而像我们一般使用的
  Yahoo、Eric Meyer 和 Alice base.css 中采用的 Reset 都没有很好地考虑中文排版。<i class="serif">Typo.css</i> 要做的就是解决中文排版的问题。</p>

<p><strong><i class="serif">Typo.css</i> 测试于如下平台:</strong></p>
<table summary="Typo.css 的测试平台列表">
  <thead>
  <tr>
    <th>OS/浏览器</th>
    <th>Firefox</th>
    <th>Chrome</th>
    <th>Safari</th>
    <th>Opera</th>
    <th>IE9</th>
    <th>IE8</th>
    <th>IE7</th>
    <th>IE6</th>
  </tr>
  </thead>
  <tbody>
  <tr>
    <td>OS X</td>
    <td>√</td>
    <td>√</td>
    <td>√</td>
    <td>√</td>
    <td>-</td>
    <td>-</td>
    <td>-</td>
    <td>-</td>
  </tr>
  <tr>
    <td>Win 7</td>
    <td>√</td>
    <td>√</td>
    <td>√</td>
    <td>√</td>
    <td>√</td>
    <td>√</td>
    <td>√</td>
    <td>-</td>
  </tr>
  <tr>
    <td>Win XP</td>
    <td>√</td>
    <td>√</td>
    <td>√</td>
    <td>√</td>
    <td>-</td>
    <td>√</td>
    <td>√</td>
    <td>√</td>
  </tr>
  <tr>
    <td>Ubuntu</td>
    <td>√</td>
    <td>√</td>
    <td>-</td>
    <td>√</td>
    <td>-</td>
    <td>-</td>
    <td>-</td>
    <td>-</td>
  </tr>
  </tbody>
</table>

<h4>中文排版的重点和难点</h4>

<p>在中文排版中,HTML4 的很多标准在语义在都有照顾到。但从视觉效果上,却很难利用单独的 CSS 来实现,像<abbr title="在文字下多加一个点">着重号</abbr>(例:这里<em class="typo-em">强调一下</em>)。在 HTML4 中,专名号标签(<code>&lt;u&gt;</code>)已经被放弃,而
  HTML5 被<a href="http://html5doctor.com/u-element/">重新提起</a>。<i class="serif">Typo.css</i> 也根据实际情况提供相应的方案。我们重要要注意的两点是:</p>
<ol>
  <li>语义:语义对应的用法和样式是否与中文排版一致</li>
  <li>表现:在各浏览器中的字体、大小和缩放是否如排版预期</li>
</ol>
<p>对于这些,<i class="serif">Typo.css</i> 排版项目的中文偏重注意点,都添加在附录中,详见:</p>
<blockquote>
  <b>附录一</b>:<a href="#appendix1"><i class="serif">Typo.css</i> 排版偏重点</a>
</blockquote>

<p>目前已有像百姓网等全面使用 <i class="serif">Typo.css</i> 的项目,测试平台的覆盖,特别是在<abbr title="手机、平板电脑等移动平台">移动端</abbr>上还没有覆盖完主流平台,希望有能力的同学能加入测试行列,或者加入到 <i class="serif">Typo.css</i>
  的开发。加入方法:<a href="https://github.com/sofish/Typo.css">参与 <i class="serif">Typo.css</i> 开发</a>。如有批评、建议和意见,也随时欢迎给在 Github 直接提 <a
    href="https://github.com/sofish/Typo.css/issues">issues</a>,或给<abbr title="Sofish Lin, author of Typo.css"
                                                                        role="author">我</abbr>发<a
    href="mailto:sofish@icloud.com">邮件</a>。</p>


<h2 id="section2">二、排版实例:</h2>

<p>提供2个排版实例,第一个中文实例来自于来自于<cite class="typo-unique">张燕婴</cite>的《论语》,由于古文排版涉及到的元素比较多,所以采用《论语》中《学而》的第一篇作为排版实例介绍;第2个来自到经典的
  Lorem Ipsum,并加入了一些代码和列表等比较具有代表性的排版元素。</p>

<h3 id="section2-1">例1:论语学而篇第一</h3>

<p>
  <small><b>作者:</b><abbr title="名丘,字仲尼">孔子</abbr>(
    <time>前551年9月28日-前479年4月11日</time>
    )
  </small>
</p>

<h4>本篇引语</h4>

<p>
  《学而》是《论语》第一篇的篇名。《论语》中各篇一般都是以第一章的前二三个字作为该篇的篇名。《学而》一篇包括16章,内容涉及诸多方面。其中重点是「吾日三省吾身」;「节用而爱人,使民以时」;「礼之用,和为贵」以及仁、孝、信等道德范畴。 </p>

<h4>原文</h4>

<p>子曰:「学而时习之,不亦说乎?有朋自远方来,不亦乐乎?人不知,而不愠,不亦君子乎?」 </p>

<h4>译文</h4>

<p>孔子说:「学了又时常温习和练习,不是很愉快吗?有志同道合的人从远方来,不是很令人高兴的吗?人家不了解我,我也不怨恨、恼怒,不也是一个有德的君子吗?」 </p>

<h4>评析</h4>

<p>宋代著名学者<u class="typo-u">朱熹</u>对此章评价极高,说它是「入道之门,积德之基」。本章这三句话是人们非常熟悉的。历来的解释都是:学了以后,又时常温习和练习,不也高兴吗等等。三句话,一句一个意思,前后句子也没有什么连贯性。但也有人认为这样解释不符合原义,指出这里的「学」不是指学习,而是指学说或主张;「时」不能解为时常,而是时代或社会的意思,「习」不是温习,而是使用,引申为采用。而且,这三句话不是孤立的,而是前后相互连贯的。这三句的意思是:自己的学说,要是被社会采用了,那就太高兴了;退一步说,要是没有被社会所采用,可是很多朋友赞同<abbr
  title="张燕婴">我</abbr>的学说,纷纷到我这里来讨论问题,我也感到快乐;再退一步说,即使社会不采用,人们也不理解我,我也不怨恨,这样做,不也就是君子吗?(见《齐鲁学刊》1986年第6期文)这种解释可以自圆其说,而且也有一定的道理,供读者在理解本章内容时参考。
</p>

<p>此外,在对「人不知,而不愠」一句的解释中,也有人认为,「人不知」的后面没有宾语,人家不知道什么呢?当时因为孔子有说话的特定环境,他不需要说出知道什么,别人就可以理解了,却给后人留下一个谜。有人说,这一句是接上一句说的,从远方来的朋友向我求教,我告诉他,他还不懂,我却不怨恨。这样,「人不知」就是「人家不知道我所讲述的」了。这样的解释似乎有些牵强。</p>

<p>总之,本章提出以学习为乐事,做到人不知而不愠,反映出孔子学而不厌、诲人不倦、注重修养、严格要求自己的主张。这些思想主张在《论语》书中多处可见,有助于对第一章内容的深入了解。</p>

<h3 id="section2-2">例2:英文排版</h3>

<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
  standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a
  type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining
  essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
  passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem
  Ipsum.</p>
<blockquote>
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
  aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</blockquote>

<h4>The standard Lorem Ipsum passage, used since the 1500s</h4>

<p>"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
  aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
  occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>

<h4>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC</h4>

<p>"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam,
  eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam
  voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione
  voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci
  velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim
  ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi
  consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur,
  vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>

<h4>List style in action</h4>
<ul>
  <li>If you wish to succeed, you should use persistence as your good friend, experience as your reference, prudence as
    your brother and hope as your sentry.
    <p>如果你希望成功,当以恒心为良友,以经验为参谋,以谨慎为兄弟,以希望为哨兵。</p>
  </li>
  <li>Sometimes one pays most for the things one gets for nothing.
    <p>有时候一个人为不花钱得到的东西付出的代价最高。</p>
  </li>
  <li>Only those who have the patience to do simple things perfectly ever acquire the skill to do difficult things
    easily.
    <p>只有有耐心圆满完成简单工作的人,才能够轻而易举的完成困难的事。</p>
  </li>
</ul>

<h4>You may want to create a perfect <code>&lt;hr /&gt;</code> line, despite the fact that there will never have one
</h4>
<hr/>
<p><abbr title="法国作家罗切福考尔德">La Racheforcauld</abbr> said:
  <mark>"Few things are impossible in themselves; and it is often for want of will, rather than of means, that man fails
    to succeed".
  </mark>
  You just need to follow the browser's behavior, and set a right <code>margin</code> to it。it will works nice as the
  demo you're watching now. The following code is the best way to render typo in Chinese:
</p>
<pre>
/* 标题应该更贴紧内容,并与其他块区分,margin 值要相应做优化 */
h1,h2,h3,h4,h5,h6 {
    line-height:1;font-family:Arial,sans-serif;margin:1.4em 0 0.8em;
}
h1{font-size:1.8em;}
h2{font-size:1.6em;}
h3{font-size:1.4em;}
h4{font-size:1.2em;}
h5,h6{font-size:1em;}

/* 现代排版:保证块/段落之间的空白隔行 */
.typo p, .typo pre, .typo ul, .typo ol, .typo dl, .typo form, .typo hr {
    margin:1em 0 0.6em;
}
</pre>

<h3 id="section3">三、附录</h3>

<h5 id="appendix1">1、<i class="serif">Typo.css</i> 排版偏重点</h5>
<table summary="Typo.css 排版偏重点">
  <thead>
  <tr>
    <th>类型</th>
    <th>语义</th>
    <th>标签</th>
    <th>注意点</th>
  </tr>
  </thead>
  <tbody>
  <tr>
    <th rowspan="15">基础标签</th>
    <td>标题</td>
    <td><code>h1</code> ~ <code>h6</code></td>
    <td>全局不强制大小,<code>.typo</code> 中标题与其对应的内容应紧贴,并且有相应的大小设置</td>
  </tr>
  <tr>
    <td>上、下标</td>
    <td><code>sup</code>/<code>sub</code></td>
    <td>保持与 MicroSoft Office Word 等程序的日常排版一致</td>
  </tr>
  <tr>
    <td>引用</td>
    <td><code>blockquote</code></td>
    <td>显示/嵌套样式</td>
  </tr>
  <tr>
    <td>缩写</td>
    <td><code>abbr</code></td>
    <td>是否都有下划线,鼠标 <code>hover</code> 是否为帮助手势</td>
  </tr>
  <tr>
    <td>分割线</td>
    <td><code>hr</code></td>
    <td>显示的 <code>padding</code> 和 <code>margin</code>正确</td>
  </tr>
  <tr>
    <td>列表</td>
    <td><code>ul</code>/<code>ol</code>/<code>dl</code></td>
    <td>在全局没有 <code>list-style</code>,在 .<code>typo</code> 中对齐正确</td>
  </tr>
  <tr>
    <td>定义列表</td>
    <td><code>dl</code></td>
    <td>全局 <code>padding</code> 和 <code>margin</code>为0, .<code>typo</code> 中对齐正确</td>
  </tr>
  <tr>
    <td>选项</td>
    <td><code>input[type=radio[, checkbox]]</code></td>
    <td>与其他 <code>form</code> 元素排版时是否居中</td>
  </tr>
  <tr>
    <td>斜体</td>
    <td><code>i</code></td>
    <td>只设置一种斜体,让 <code>em</code> 和 <code>cite</code> 显示为正体</td>
  </tr>
  <tr>
    <td>强调</td>
    <td><code>em</code></td>
    <td>在全局显示正体,在 <code>.typo</code> 中显示与 <code>b</code> 和 <code>strong</code> 的样式一致,为粗体</td>
  </tr>
  <tr>
    <td>加强</td>
    <td><code>strong/b</code></td>
    <td>显示为粗体</td>
  </tr>
  <tr>
    <td>标记</td>
    <td><code>mark</code></td>
    <td>类似荧光笔</td>
  </tr>
  <tr>
    <td>印刷</td>
    <td><code>small</code></td>
    <td>保持为正确字体的 80% 大小,颜色设置为浅灰色</td>
  </tr>
  <tr>
    <td>表格</td>
    <td><code>table</code></td>
    <td>全局不显示线条,在 <code>table</code> 中显示表格外框,并且表头有浅灰背景</td>
  </tr>
  <tr>
    <td>代码</td>
    <td><code>pre</code>/<code>code</code></td>
    <td>字体使用 <code>courier</code> 系字体,保持与 <code>serif</code> 有比较一致的显示效果</td>
  </tr>
  <tr>
    <th rowspan="5">特殊符号</th>
    <td>着重号</td>
    <td><em class="typo-em">在文字下加点</em></td>
    <td>在支持 <code>:after</code> 和 <code>:before</code> 的浏览器可以做渐进增强实现</td>
  </tr>
  <tr>
    <td>专名号</td>
    <td><u>林建锋</u></td>
    <td>专名号,有下划线,使用 <code>u</code> 或都 <code>.typo-u</code> 类</td>
  </tr>
  <tr>
    <td>破折号</td>
    <td>——</td>
    <td>保持一划,而非两划</td>
  </tr>
  <tr>
    <td>人民币</td>
    <td>&yen;</td>
    <td>使用两平等线的符号,或者 HTML 实体符号 <code>&amp;yen;</code></td>
  </tr>
  <tr>
    <td>删除符</td>
    <td>
      <del>已删除(deleted)</del>
    </td>
    <td>一致化各浏览器显示,中英混排正确</td>
  </tr>
  <tr>
    <th rowspan="3">加强类</th>
    <td>专名号</td>
    <td><code>.typo-u</code></td>
    <td>由于 <code>u</code> 被 HTML4 放弃,在向后兼容上推荐使用 <code>.typo-u</code></td>
  </tr>
  <tr>
    <td>着重符</td>
    <td><code>.typo-em</code></td>
    <td>利用 <code>:after</code> 和 <code>:before</code> 实现着重符</td>
  </tr>
  <tr>
    <td>清除浮动</td>
    <td><code>.clearfix</code></td>
    <td>与一般 CSS Reset 保持一对致 API</td>
  </tr>
  <tr>
    <th rowspan="5">注意点</th>
    <td colspan="3">(1)中英文混排行高/行距</td>
  </tr>
  <tr>
    <td colspan="3">(2)上下标在 IE 中显示效果</td>
  </tr>
  <tr>
    <td colspan="3">(3)块/段落分割空白是否符合设计原则</td>
  </tr>
  <tr>
    <td colspan="3">(4)input 多余空间问题</td>
  </tr>
  <tr>
    <td colspan="3">(5)默认字体色彩,目前采用 <code>#333</code> 在各种浏览显示比较好</td>
  </tr>
  </tbody>
</table>

<h5 id="appendix2">2、开源许可</h5>

<p><i class="serif">Typo.css</i> 基于 <a href="http://zh.wikipedia.org/wiki/MIT_License">MIT License</a> 开源,使用代码只需说明来源,或者引用 <a
  href="http://typo.sofi.sh/license.txt">license.txt</a> 即可。</p>
</div>
<!-- #wrapper -->
<a href="https://github.com/sofish/Typo.css" id="fork">
  <img alt="Fork me on GitHub" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png">
</a>

</body>
</html>

 

效果图:

 

中文网页重设与排版:
目标:一致化浏览器排版效果,构建最适合中文阅读的网页排版。包括桌面和移动平台。
预览:typo.css

一、目录结构
├── README.md           --- 使用帮助
├── license.txt         --- 许可证
├── typo.css            --- 将应用于你的项目
└── typo.html           --- Demo/预览

二、TYPO.CSS 的设计和使用
TYPO.CSS 主要包括:
1、一般 reset.css 所需的内容
目前的设计是这样的,尽量保持完整的 reset,比如让 ul/ol 无样式并且无多余的 padding/margin,这是必须的,因为一个网可能需要很多自定义的的内容,在实践中我们并不希望像 ul/ol 有样式,这样我们得用优先级去覆盖,这是非常麻烦的事。所以 typo.css 并不像 normalize.css,后者给每一个元素都预先定义了样式,这样在自定义的时候将是非常痛苦的。要大保持干净的所有元素一致化的 reset 才是最佳实践。

2、class="typo" 阅读内容排版
在文章/文档阅读的页面,需添加 .typo 这个 class,这样 table/ol/ul 等都会有预定的样式,让你的排版像 http://typo.sofi.sh 一样,让用户阅读起来更舒服。
在父容器在没有添加 class="typo" 的时候,可以使用 class="typo-标签"(如 class="typo-ul")来实现像 .typo > ul 这样结构的样式。

3、增加类:
主要是一些需要中文日常排版需要的元素和语文对应样式的增强,目前包括:
(1) 专名号:使用标签 <u> 或者 .typo-u
(2) 着重号:使用 class .typo-em
(3) 清理浮动:与一般 reset.css 保持一致 .clearfix
(4) 强制换行:添加 .textwrap 到文本所在的容器,如果是 table 测还需要 .textwrap-table
(5) 衬线字体:添加 .serif
(6) 创建 border-box:在 html 中添加 .borderbox #why

三、开源许可
基于 MIT License 开源,使用代码只需说明来源,或者引用 license.txt 即可。

参考来源:https://github.com/sofish/typo.css 打开链接

 

 

 

 

 

 

 

 

 

 

  • 大小: 88.5 KB
分享到:
评论

相关推荐

    中文网页重设与排版typo.css.zip

    中文网页重设与排版: 目标:一致化浏览器排版效果,构建最适合中文阅读的网页排版。包括桌面和移动平台。 Alpha 中,各路牛人都来支持一下,加入开发啊! 预览:typo.css 一、目录结构 . ├── README.md --- 使用...

    typo.css:中文网页重设与布局:一致化浏览器布局效果,打造最适合中文阅读的网页布局

    中文网页重设与布局: 目标:一致化浏览器布局效果,内置最适合中文阅读的网页布局。包括桌面和移动平台。 预览: 一,目录结构 . ├── README.md --- 使用帮助 ├── license.txt --- 许可证 ├── typo.css -...

    mweb-themes:30+ 款 Markdown 预览主题,Typo.css、Vue、Bear 等风格,适用于 MWeb、Typora

    MWeb-Themes30+ 款 Markdown 预览主题,包括 、、、 等风格,适用于 MWeb、Typora 等笔记软件。目录使用主题在 MWeb 中使用在 Typora 中使用开发主题主题列表浅色主题ayubear-defaultcontrastd-boringdefaultduotone...

    pycharm中显示CSS提示的知识点总结

    然后在右侧找到CSS,选择typo,如下图所示 接着点击apply和ok按钮,如下图所示 然后新建一个html页面,如下图所示 最后写CSS的时候就会弹出提示了,如下图所示 综上所述,pycharm中显示CSS提示就在Editor下面的...

    无侵入的Bootstrap定制版EvaBootstrap.zip

    通过引入typo.css项目,提供更好的中文排版支持。 对于需要采用中文排版的元素,加上class .typocn 高级别CSS Reset TB的CSS Reset采用的是normalize.css,这种Reset以修复浏览器缺陷为主要目的,在实际项目中...

    geras:兼容IE6的前端框架

    基于typo.css的样式重设、中文友好的排版样式 支持&lt;a&gt; 和 &lt;button&gt;标签的按钮样式. 垂直和水平的菜单 常见的表格样式 菜单 表单 基于KISSY UI的常用JS组件,下拉菜单、提示框等等 浏览器兼容 demeter在以下...

    TYPO3 中文版 v7.3.1.zip

    TYPO3是一个企业级的开源内容管理系统,可以用来建设和管理各种类型的网站,从小站点、非盈利组织到针对大型企业的多语言企业级解决方案。 极益平台1.0版本将基于TYPO3 7.3.1。系统包括前台、业务后台、总后台三个...

    typo3中文 教程

    kickstarter_chs typo3

    typo.vim:vim 的错别字包装器

    ~/.vimrc添加到您的~/.vimrc : " `:Typo` command generates type table." `:TypoTags` command generates `tags` table." NOTE: you must run this where `"%"` is crate root.command ! Typo call typo#generate...

    TYPO3 建站指南中文版 (Building websites with typo3)

    TYPO3 建站指南中文版 TYPO3 建站指南中文版 TYPO3 建站指南中文版 TYPO3 建站指南中文版

    TYPO3.CMS:TYPO3核心-企业内容管理系统。 http:git.typo3.orgPackagesTYPO3.CMS.git的同步只读镜像

    TYPO3 CMS TYPO3是在GNU GPL下发布的基于PHP的开源Web内容管理系统。 TYPO3是Kasper Skaarhoj版权所有(c)1999-2020。 本文档提供了TYPO3的基本介绍。 入门 TYPO3需要具有PHP的Web服务器和数据库(例如MySQL)。 ...

    TYPO3简体中文语言包

    TYPO3简体中文语言包,按说明解压使用即可。。。

    TYPO3.Neos:TYPO3.Neos 包的个人游乐场

    TYPO3.Neos 包 什么是TYPO3.Neos? TYPO3 Neos是TYPO3社区打造的下一代开源内容管理系统。... 请通过邮件列表或 IRC(irc.freenode.net、频道 #typo3-flow 或 #typo3-neos)与我们联系,以便我们可以找到指导您贡献的

    Typo3 内容管理系统 v6.2.2.zip

    TYPO3 6.2.2 更新说明: 修复了一个重要的 bug, 修复了 6.2.1 的一些回退问题, 建议 6.2.1 和 6.2.0 的用户尽快升级。   TYPO3是一个企业级的开源内容管理系统,可以用来建设和管理各种类型的网站,从小站点...

    Typo3 v4.5.18 LTS.zip

    Typo3是开源内容管理系统(CMS)和内容管理框架(CMF)的领导性品牌之一,和CMSware一样是一个真正的高端企业级的产品;由于其不是面向低端用户的产品,因而在国内影响相当有限。 Typo3主要是面向中高级php水平的开发者...

    typo3cms V7.6.18建站源码

    Typo3内容管理系统,是基于PHP4/PHP5+MYsql的内容管理系统(框架)(CMS/CMF),...数据库系统除Mysql之外,也能运行于Oracle, MS-SQL, ODBC, LDAP 等其它数据库系统,支持Typo3的服务器系统:Apache或者IIS架设的服务器。

    [CMS程序]Typo3 dummy 4.110 (集成后台简体中文语言包)(PHP4+)_typo3_src4.zip

    [CMS程序]Typo3 dummy 4.110 (集成后台简体中文语言包)(PHP4+)_typo3_src4.zip

    typo3 入门教程

    typo3 入门教程 简单介绍Typo 3 116 sites

    TYPO3 中文版 v7.6 LTS

    TYPO3是一个企业级的开源内容管理系统,可以用来建设和管理各种类型的网站,从小站点、非盈利组织到针对大型企业的多语言企业级解决方案。极益平台1.0版本将基于TYPO3 7.3.1。系统包括前台、业务后台、总后台三个...

    Blog:个人博客源代码

    Markdown -内容排版:typo.css -动画:animate.css -代码高亮:棱镜-目录生成:Tocbot -滚动侦测:航点-平滑滚动:jquery.scrollTo -二维码生成:qrcode.js参考的网站: -背景: : -图片查找: ://unsplash.it -首图...

Global site tag (gtag.js) - Google Analytics