針對webkit的HTML, CSS和Javascript(記錄)

HTML, 從HTML文檔的開端到停止分列:


<meta name=”viewport” content=”width=device-width, initial-scale=1.0″/> 讓內容的寬度自適應爲設備的寬度, 在做Mobile Web時必須加的一條


<meta name=”format-detection” content=”telephone=no”]]> 禁用號碼鏈接(for iPhone)


<link rel=”apple-touch-icon” href=”icon.png”/> 設置你網頁的圖標, 尺寸爲57X57 px


<!– iOS 2.0+: tell iOS not to apply any glare effects to the icon –>


<link rel=”apple-touch-icon-precomposed” href=”icon.png”/>


<!– iOS 4.2+ icons for different resolutions –>


<link rel=”apple-touch-icon” sizes=”72×72″ href=”touch-icon-ipad.png” />


<link rel=”apple-touch-icon” sizes=”114×114″ href=”touch-icon-iphone4.png” />


<link rel=”apple-touch-startup-image” href=”startup.png”> 全屏啓動時辰的啓動畫面圖像, 尺寸320X460 px


<meta name=”apple-mobile-web-app-capable” content=”yes” /> 是否容許全屏顯示, 只有在桌面啓動時可用


<meta name=”apple-mobile-web-app-status-bar-style” content=”black” /> 把握全屏時頂部狀況欄的外觀, 默認白色


<input autocorrect=”off” autocomplete=”off” autocapitalize=”off”>  作廢主動完成, 主動大寫單詞字母(實用於Mobile上)


<input type=”text” x-webkit-speech /> 語音輸入


<input type=”file” accept = “image/*; capture=camera” /> 文件上傳, 從相機捕獲媒體, 下同


<input type=”file” accept = “video/*; capture=camcorder” />


<input type=”file” accept = “audio/*; capture=microphone” />


<a href=”sms:18005555555,18005555556″]]> 發送給多小我 的鏈接


<a href=”sms:18005555555?body=Text%20goes%20here”]]> 發送附帶內容 的鏈接


<a href=”tel:18005555555″]]>Call us at 1-800-555-5555</a]]> 撥打德律風 的鏈接


CSS:


-webkit-tap-highlight-color: transparent; Mobile上點擊鏈接高亮的時辰設置色彩爲透明


-webkit-user-: none; 設置爲無法選擇文本


-webkit-touch-callout: none; 長按時不觸發體系的菜單, 可用在上加這個屬性禁止


:-webkit-full-screen canvas {} 全屏模式時的樣式(for Desktop)


div p :matches(em, b, strong) {} 應用mathes來匹配多個選擇器


@media only screen and (max-width: 480px) {} 指定Mobile設備或者小屏幕桌面屏幕


@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 300dpi) { 指定高辨別率屏幕設備


header { background-image: url(header-highres.png); }


}


@media (-webkit-max-device-pixel-ratio: 1.5),(max-resolution: 299dpi) { 指定低辨別率屏幕設備


header { background-image: url(header-lowres.png); }


}


background-repeat:  space; background-repeat: round; 這兩種CSS3的靠山屬性值得研究


width: calc(100%-40px); 策畫寬度


text-decoration: #FF8800  wavy ine-through; 波浪型鏈接


text-rendering: optimizeLegibility; 用這個屬性之後會收緊字符間的間隔


font-variant-ligatures:  common-ligatures; 設置CSS連字


transform:  rotate(90); 扭轉90度


transform-origin: center center; transform-origin可以改變變換的地位


-webkit-appearance: none; -webkit-appearance可以改變按鈕或者其它控件看起來類似本地的控件


美化表單校驗時的提示樣式


::-webkit-validation-bubble {}


::-webkit-validation-bubble-message {}

::-webkit-validation-bubble-arrow {}

::-webkit-validation-bubble-arrow-clipper {}

當提示呈現時類似於下面的佈局


<div -webkit-validation-bubble>


<div -webkit-validation-bubble-arrow></div>

<div -webkit-validation-bubble-arrow-clipper></div>

<div -webkit-validation-bubble-message>Error Message</div>

</div>

自定義webkit瀏覽器的遷移轉變條, 見Google Reader等在Chrome/Safari下的結果, 下面是一個實例, 這個遷移轉變條的樣式代碼如下:


Customized WebKit Scrollbar /* Let´s get this party started */


::-webkit-scrollbar {

width: 12px;

}

/* Track */

::-webkit-scrollbar-track {

-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);

-webkit-border-radius: 10px;

border-radius: 10px;

}

/* Handle */

::-webkit-scrollbar-thumb {

-webkit-border-radius: 10px;

border-radius: 10px;

background: rgba(255,0,0,0.8);

-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);

}

::-webkit-scrollbar-thumb:window-inactive {

background: rgba(255,0,0,0.4);

}

-webkit-background-composite: plus-darker; -webkit-background-composite用來設置一個元素的靠山或色彩的組合樣式


-webkit-text-stroke:  1px rgba(0,0,0,0.5); -webkit-text-stroke可以用來給文字添加描邊


-webkit-mask-image:  url(/path/to/mask.png); 定義一個用來遮罩元素


-webkit-box-reflect:  below 5px; 定義了一個元素的反射


:local-link {font-weight: normal;}  local-link可以定義相對地址的鏈接樣式


Javascript:


window.scrollTo(0,0); 隱蔽地址欄


window.matchMedia(); 匹配媒體


navigator.connection; 決意是否運行在WiFi/3G等收集


window.devicePixelRatio; 決意屏幕辨別率(iPhone 4值爲2, 而Nexus One值爲1.5)


window.navigator.onLine; 取得收集連接狀況


window.navigator.standalone; 決意iPhone是否處於全屏狀況


touch事務 (iOS, Android 2.2+): touchstart, touchmove, touchend, touchcancel


gesture事務 (Apple only, iOS 2+):  gesturestart, gesturechange, gesturend give access to predefined gestures (rotation, scale, position)


window.addEventListener("orientationchange", function(e){


//window.orientation(0 is portrait, 90 and -90 are landscape)

}, false);

window.addEventListener("deviceorientation", function(e){

//e.alpha

//e.beta

//e.gamma

}, false);

window.addEventListener("devicemotion", function(e){

//e.accelerationIncludingGravity.x

//e.accelerationIncludingGravity.y

//e.accelerationIncludingGravity.z

}, false);

requestAnimationFrame() 新的動畫函數


element.webkitRequestFullScreen() 調用全屏函數


瀏覽更多:


http://www.slideshare.net/franksvalli/mobile-html-css-and-javascript


http://css-tricks.com/9130-custom-scrollbars-in-webkit/


https://developer.mozilla.org/zh-CN/docs

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章