<link rel='stylesheet' type='text/css'
media='screen' href='css/styles.css' />
<link rel='stylesheet' type='text/css'
media='print' href='css/print.css' />
@media screen {
p {
color: blue;
}
}
@media print {
p {
color: red;
}
}
<link media="screen" ...
<style> @import "myCSS.css"; ...
@import url(myCSS.css) screen; IE8+
@media screen {}
<?xml-stylesheet media="screen" ...
<link rel='stylesheet' media='screen and (min-width: 320px) and (max-width: 480px)'
href='css/smartphone.css' />
@media screen and (max-width: 480px){
a {
transition: background-color 200ms linear 50ms;
}
}
@media screen and (orientation: landscape) {
a[href^="mailto:]:before {
content: url(icons/email.gif);
}
}
media="only print and (color)" media="only screen and (orientation: portrait)" media="not screen and (color)" media="print, screen and (min-width: 480px)"
@media screen and (-webkit-min-device-pixel-ratio: 2) {
.iphone4 { /* high DPI */}
}
@screen and (transform-3d) {
.transforms {}
}
Also works with (animation) and (transition)
body {
-<prefix>-transition: all 1.5s linear;
}
@media only screen and (orientation: portrait) {
body{
background: indianred;
}
}
@media only screen and (max-width: 480px) {
body{
background: palegoldenrod;
}
}
shrink this window to see the presentation change colors
Forcing portrait mode
@media only screen and (max-device-width: 480px) and (orientation: landscape){
#containerDiv{
-webkit-transform:rotate(-90deg);
-webkit-transform-origin: 160px 160px;
}
}
Forcing Landscape Mode
@media only screen and (max-device-width: 480px) and (orientation: portrait){
#containerDiv{
-webkit-transform:rotate(90deg) scale(1.45);
-webkit-transform-origin: 230px 230px;
}
}
switch(window.orientation){
case 0:
//handle portrait actions
//document.getElementsByTagName('body')[0].className = 'portrait';
break;
case -90:
case 90:
// handle landscape actions
//document.getElementsByTagName('body')[0].className = 'landscape';
break;
} //end switch
Event
onOrientationChange
Home Screen Icons
<link rel="apple-touch-icon" href="icon.png" sizes="114x114"/> <link rel="apple-touch-icon-precomposed" href="roundicon.png" />
Status Bar Color
<meta name="apple-mobile-web-app-status-bar-style"
content="black-translucent">
(default | black | black-translucent)
Start-up Image
<link rel="apple-touch-startup-image" href="fullscreen.jpg"/>
Targeting the PhoneViewport:
<meta name="viewport" content="width=device-width"/> <meta name="viewport" content="user-scalable=no, width=device-width"/ <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />
Last one prevents zoom/scale
Hiding the iPhone toolbar
window.scrollTo(0, 1);
To go full screen
<meta name="apple-mobile-web-app-capable" content="yes">
:hover
-webkit-tap-highlight-color:
npm -g install weinre
weinre
<script src="http://localhost:8080/target/target-script-min.js#anonymous"></script>
http://localhost:8080/client/
::-webkit-scrollbar {
margin-right: 5px;
background-color: #bdd9d5;
border-radius: 6px;
width: 12px;
}
::-webkit-scrollbar-track {
box-shadow: 0 0 2px rgba(0,0,0,0.3);
}
::-webkit-scrollbar-thumb {
border: 1px #eee solid;
border-radius: 12px;
background: #C7573A;
box-shadow: 0 0 8px rgba(0,0,0,0.3) inset;
-webit-transition: all .3s ease-out;
transition: all .3s ease-out;
}
::-webkit-scrollbar-thumb:window-inactive {
background: #bbb;
box-shadow: 0 0 8px rgba(0,0,0,0.3) inset;
}
::-webkit-scrollbar-thumb:hover {
background: #b7472A;
}
pre {
width: 600px;
height: 200px;
overflow:auto;
}