移动端重构系列3——重置样式

移动端重构系列-mobile

本系列文章,如果没有特别说明,兼容安卓4.0.4+,测试demo

基于Normalize.css,根据目前我们大家的使用习惯进行了一些清零及移动端的特点添加一些基础样式。

html { font-family: "Helvetica Neue", Helvetica, STHeiTi, Arial, sans-serif; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; font-size: 62.5%; }
body { margin: 0; font-size: 1.4rem; line-height: 1.5; color: #333333; background-color: white; height: 100%; overflow-x: hidden; -webkit-overflow-scrolling: touch; }

article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary { display: block; }
audio, canvas, progress, video { display: inline-block; vertical-align: baseline; }
audio:not([controls]) { display: none; height: 0; }
[hidden], template { display: none; }
svg:not(:root) { overflow: hidden; }

a { background: transparent; text-decoration: none; -webkit-tap-highlight-color: transparent; color: #0088cc; }
a:active { outline: 0; }
a:active { color: #006699; }
abbr[title] { border-bottom: 1px dotted; }
b, strong { font-weight: bold; }
dfn { font-style: italic; }
mark { background: #ff0; color: #000; }
small { font-size: 80%; }
sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
sup { top: -0.5em; }
sub { bottom: -0.25em; }
img { border: 0; vertical-align: middle; }
hr { -moz-box-sizing: content-box;box-sizing: content-box;height:0;}pre { overflow: auto;white-space: pre;white-space: pre-wrap;word-wrap: break-word;}code, kbd, pre, samp { font-family: monospace, monospace;font-size:1em;}button, input, optgroup, select, textarea { color: inherit;font: inherit;margin:0;}button { overflow: visible;}button, select { text-transform: none;}button, html input[type="button"], input[type="reset"], input[type="submit"] { -webkit-appearance: button;cursor: pointer;}button[disabled], html input[disabled] { cursor: default;}button::-moz-focus-inner, input::-moz-focus-inner { border:0;padding:0;}input { line-height: normal;}input[type="checkbox"], input[type="radio"] { box-sizing: border-box;padding:0;}input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { height: auto;}input[type="search"] { -webkit-appearance: textfield;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;}input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none;}fieldset { border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em;}legend { border:0;padding:0;}textarea { overflow: auto;resize: vertical;}optgroup { font-weight: bold;}table { border-collapse: collapse;border-spacing:0;}td, th { padding:0;}html, button, input, select, textarea { font-family:"Helvetica Neue", Helvetica, STHeiTi, Arial, sans-serif;}h1, h2, h3, h4, h5, h6, p, figure, form, blockquote { margin:0;}ul, ol, li, dl, dd { margin:0;padding:0;}ul, ol { list-style: none outside none;}h1, h2, h3 { line-height:2;font-weight: normal;}h1 { font-size:1.8rem;}h2 { font-size:1.6rem;}h3 { font-size:1.4rem;}input::-moz-placeholder, textarea::-moz-placeholder { color:#cccccc;}input:-ms-input-placeholder, textarea:-ms-input-placeholder { color:#cccccc;}input::-webkit-input-placeholder, textarea::-webkit-input-placeholder { color:#cccccc;}

* { -webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;}

具体说明请参考sandal中的reset文件

这里有两点需要说明:

1、关于moz前缀

因为本人习惯使用firefox浏览器,所以没有舍弃moz前缀,而且moz前缀也不多,就几个而已,所以没有去掉。如有代码洁癖者,可去掉。

2、关于字体

font-family: "Helvetica Neue", Helvetica, STHeiTi, Arial, sans-serif;

IOS

iOS 4.0+ 使用英文字体 Helvetica Neue,之前的iOS版本降级使用 Helvetica,中文字体设置为华文黑体STHeiTi。

Android

原生Android下中文字体与英文字体都选择默认的无衬线字体,4.0之前版本英文字体原生Android使用的是Droid Sans,中文字体原生Android会命中Droid Sans Fallback,4.0+ 中英文字体都会使用原生Android新的Roboto字体。其他第三方Android系统也一致选择默认的无衬线字体。

最后加上Arial字体方便pc端查看效果。

参考资料:字体设置

如需转载,烦请注明出处:http://www.w3cplus.com/mobile/mobile-terminal-refactoring-reset-style.html

时间: 2024-08-26 19:59:27

移动端重构系列3——重置样式的相关文章

移动端重构系列6——图标

移动端重构系列-mobile 本系列文章,如果没有特别说明,兼容安卓4.0.4+ 这里我们把图标分为三种:背景图片,直接绘制,@font-face.如无特殊情况,图标的标签采用i标签 背景图片 首先我们会选择sprite形式,把所有的图标都放在一个大图中,然后考虑到retina屏,所以我们的图标应该设计为实际大小的2倍,然后设置background-size为实际大小.以下面的msg icon为例: 图中的每个icon大小为24px,实际应用时,我们是以12px来使用的: %icon-msg{

移动端重构系列1——新建空白页面

移动端重构系列-mobile 本系列文章,如果没有特别说明,兼容安卓4.0.4+,测试demo html5文档申明 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> </body> </html> meta标签 <meta nam

移动端重构系列5——切入切出动画

移动端重构系列-mobile 本系列文章,如果没有特别说明,兼容安卓4.0.4+ 因为后面的几篇文章都需要用到切入切出动画什么的,所以先把这个说下.为了简单起见,我们这里只讨论translate偏移动画(translate比起绝对定位的top/left/right/bottom要高效),而如其他的旋转缩放淡入淡出什么的道理都一样. transition动画 先定义要运动的元素在视觉范围之外,以左方向进入为例,同时定义transition: .demo{ @include translate3D(

移动端重构系列11——弹窗modal

copy from http://www.w3cplus.com/mobile/mobile-terminal-refactoring-modal.html 本系列文章,如果没有特别说明,兼容安卓4.0.4+ 设计结构如下: <header class="header"></header> <div class="wrap-page"> <section class="page"></sect

移动端重构系列-移动端html页面优化

对于访问量大的网站来说,前端的优化是必须的,即使是优化1KB的大小对其影响也很大,下面来看看来自ISUX的米随随讲讲移动手机平台的HTML5前端优化,或许对你有帮助和启发. 概述 1. PC优化手段在Mobile侧同样适用      2. 在Mobile侧我们提出三秒种渲染完成首屏指标      3. 基于第二点,首屏加载3秒完成或使用Loading      4. 基于联通3G网络平均338KB/s(2.71Mb/s),所以首屏资源不应超过1014KB      5. Mobile侧因手机配置

移动端重构系列12——popup

转载自http://www.w3cplus.com/mobile/mobile-terminal-refactoring-popup.html popup分为两种:一种是内容比较多,直接以全屏显示,如图一:一种是少量内容的popup提示,如图二 先上demo: popup测试 popup page 第一种形式,设计结构如下: <header class="header"></header> <div class="wrap-page"&

CSS重置样式表

一.为什么需要重置样式表 即使不写CSS样式,HTML标签在浏览器中也有样式,这些样式来自浏览器本身.但问题是,不同浏览器默认样式可能不同.CSS重置样式表就是为了解决这个问题. 二.常用的重置样式表 (1)简单暴力型 只有一行: *{margin:0; padding:0;} 通配符"*"匹配了所有的标签,通常认为性能不好. (2)归零型 (几乎)全部将标签样式清零.如YUI(http://yuilibrary.com/)的重置样式表. (3)保留基础样式型 并不是将所有标签的默认样

css reset重置样式有那么重要吗?

在以前写html代码的时候,一般都会在head里添加重置样式reset.css,其内容如下: @charset "utf-8"; html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp

Normalize.css – HTML5-ready 的css重置样式集

Normalize.css 是一个可定制的 css文件,使浏览器呈现的所有元素,更一致和符合现代标准.它正是针对只需要统一的元素样式.该项目依赖于研究浏览器默认元素风格之间的差异,精确定位需要重置的样式.这是一个现代的,HTML5-ready 的css重置样式集. Normalize.css 是 HTML5-ready 的css重置样式集 官网网站:http://www.yyyweb.com/demo/inner-show/normalize.html