您的位置:首页 > Web前端 > JavaScript

针对webkit的HTML, CSS和Javascript(记录)

2014-06-02 10:02 375 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: