解析行動端重設(reset)的實例

零下一度
發布: 2017-05-10 15:16:23
原創
2031 人瀏覽過

本文提供的是的行動端重設相關教學課程,有興趣的夥伴們可以關註一下,具體實例程式碼請看下文:

* {
 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; }
登入後複製

/*知識擴充*/

-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的点击区域效果一致了
登入後複製

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檔案加了此屬性,其實是多餘。

-webkit-appearance
-webkit-appearance: none;//消除输入框和按钮的原生外观,在iOS上加上这个属性才能给按钮和输入框自定义样式
登入後複製

不同type的input使用這個屬性之後表現不一。 text、button無樣式,radio、checkbox直接消失

-webkit-user-select
-webkit-user-select: none; // 禁止页面文字选择 ,此属性不
继承一般加在body上规定整个body的文字都不会自动调整
登入後複製
-webkit-text-size-adjust
-webkit-text-size-adjust: none; //禁止文字自动调整大小(默认情况下旋转设备的时候文字大小会发生变化),此属性也不继承,一般加在body上规定整个body的文字都不会自动调整
登入後複製
.-webkit-touch-c
all
out
-webkit-touch-callout:none; // 禁用长按页面时的弹出菜单(iOS下有效) ,img和a标签都要加
登入後複製
-webkit-overflow-scrolling-webkit-overflow-scrolling:touch;// 局部滚动(仅iOS 5以上支持)
登入後複製

的用處

在手機上瀏覽時,該標籤用於指定是否將網頁內容中的手機號碼顯示為撥號的超連結
在iPhone 上預設值是:

<meta name="format-detection" content="telephone=yes"/>
登入後複製

如果你不希望手機自動將網頁中的電話號碼顯示為撥號的超鏈接,那麼可以這樣寫:

<meta name="format-detection" content="telephone=no"/>
登入後複製
<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就不用加了,預設就是顯示。

<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:半透明灰色
登入後複製

【相關推薦】

1. 免費html線上影片教學

2. html開發手冊

3. php.cn原始html5影片教學

以上是解析行動端重設(reset)的實例的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!