本文轉載於:猿2048網站➧移動端resetphp
* {
margin: 0;
padding: 0;
}
article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary {
display: block;
}
html {
font-size: 12px;
color: #666;
font-family: 'Microsoft Yahei' 'Helvetica Neue', Helvetica, STHeiTi, Arial, sans-serif;
}
body{
height: 100%; overflow-x: hidden; -webkit-overflow-scrolling: touch;
}
audio, canvas, progress, video { display: inline-block; vertical-align: baseline; }
img {
border: none;
vertical-align: middle;
}
a {
text-decoration: none;
outline: none;
/*設置的tap A標籤的時候出現的黑色高亮*/
-webkit-tap-highlight-color: transparent;
}
a:active { outline: 0; }
.clearfix {
zoom: 1;
}
.clearfix:before,
.clearfix:after {
content: '';
display: table;
}
.clearfix:after {
clear: both;
}
em {
font-style: normal;
}
input {
outline: none;
}
input[type="text"],
input[type="tel"] {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
/* 去除iphone ipad 設備默認按鈕樣式 */
input[type="button"], input[type="submit"], input[type="reset"] {
-webkit-appearance: none;
border-radius: 0;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none !important;
margin: 0;
}
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; }html
/*知識擴展*/
1.-webkit-tap-highlight-color
-webkit-tap-highlight-color:rgba(0,0,0,0);//透明度設置爲0,去掉點擊連接和文本框對象時默認的灰色半透明覆蓋層(iOS)或者虛框(Android)
-webkit-tap-highlight-color:rgba(255,0,0,0.5); //利用此屬性,設置touch時連接區域高亮爲50%的透明紅,只在ios上起做用。android上只要使用了此屬性就表現爲邊框。在body上加此屬性,這樣就保證body的點擊區域效果一致了android
2.outline:none
(1)在pc端爲a標籤訂義這個樣式的目的是爲了取消ie瀏覽器下點擊a標籤時出現的虛線。ie7及如下瀏覽器還不識別此屬性,須要在a標籤上添加hidefocus="true"
(2)input,textarea{outline:none} 取消chrome下默認的文本框聚焦樣式
(3)在移動端是不起做用的,想要去除文本框的默認樣式能夠使用-webkit-appearance,聚焦時候默認樣式的取消是-webkit-tap-highlight-color。看到一些移動端reset文件加了此屬性,實際上是多餘。ios
3.-webkit-appearance
-webkit-appearance: none;//消除輸入框和按鈕的原生外觀,在iOS上加上這個屬性才能給按鈕和輸入框自定義樣式
不一樣type的input使用這個屬性以後表現不一。text、button無樣式,radio、checkbox直接消失
4.-webkit-user-select
-webkit-user-select: none; // 禁止頁面文字選擇 ,此屬性不繼承,通常加在body上規定整個body的文字都不會自動調整
5.-webkit-text-size-adjust
-webkit-text-size-adjust: none; //禁止文字自動調整大小(默認狀況下旋轉設備的時候文字大小會發生變化),此屬性也不繼承,通常加在body上規定整個body的文字都不會自動調整
6.-webkit-touch-callout
-webkit-touch-callout:none; // 禁用長按頁面時的彈出菜單(iOS下有效) ,img和a標籤都要加
7.-webkit-overflow-scrolling
-webkit-overflow-scrolling:touch;// 局部滾動(僅iOS 5以上支持)web
一、<meta name="format-detection"/> 的用處chrome
在手機上瀏覽時,該標籤用於指定是否將網頁內容中的手機號碼顯示爲撥號的超連接。
在 iPhone 上默認值是:
<meta name="format-detection" content="telephone=yes"/>
若是你不但願手機自動將網頁中的電話號碼顯示爲撥號的超連接,那麼能夠這樣寫:
<meta name="format-detection" content="telephone=no"/>
2.<meta name="apple-mobile-web-app-capable"/>的用處
<meta name=」apple-mobile-web-app-capable」 content=」yes」 />
這apple-mobile-web-app-capable的做用就是刪除默認的蘋果工具欄和菜單欄。content有兩個值」yes」和」no」,當咱們須要顯示工具欄和菜單欄時,這個行meta就不用加了,默認就是顯示。
3.<meta name="apple-mobile-web-app-status-bar-style"/>的用處
做用是控制狀態欄顯示樣式:
<meta name=」apple-mobile-web-app-status-bar-style」 content=」default」 />
<meta name=」apple-mobile-web-app-status-bar-style」 content=」black」 />
<meta name=」apple-mobile-web-app-status-bar-style」 content=」black-translucent」 />
default:默認; black:純黑; black-translucent:半透明灰色canvas