官术网_书友最值得收藏!

Frame rate

One would assume since you, the reader, are coming from a Flash development background, a moment should be taken to talk about frame rates or frames per second when developing HTML5 applications. Since every asset in Flash applications is based on the timeline model, calculating how many frames of that timeline are displayed every second is a pretty simple calculation. However, all the technologies that make up HTML5 development do not rely on the use of a timeline during runtime. Therefore calculating the frames per second or FPS value of a webpage is not always an accurate measure of performance of your HTML5 projects.

Tip

Our CSS 3D Transform example found in the chapter code examples includes the use of a great piece of JavaScript called Stats.js to monitor the frames per second as well as the ms. Stats.js is a open source project that can be found at https://github.com/mrdoob/stats.js.

Developing for mobile

Another one of the driving forces behind the popularity of HTML5 is the overwhelming support for it on most of the modern mobile browsers (http://mobilehtml5.org). With the loss of Flash Player on all mobile platforms now, the use of HTML5 to deliver content is at an all time high and the usage is growing daily. Applications, frameworks, and templates such as jQuery Mobile (http://jquerymobile.com), Phone Gap (http://phonegap.com), Appcelerator (http://www.appcelerator.com) and the Mobile Boilerplate (http://html5boilerplate.com/html5boilerplate.com/dist/mobile) all of which will be covered in detail in Chapter 5, Code Once, Release Everywhere, are all specifically built to aid web developers for building web content that is specifically targeted for mobile viewing. CSS can be set up in a responsive manner to allow the same page content to be displayed in an optimized format depending on the device and viewport configuration a user is viewing your content with.

Responsive layouts

The term "responsive layout" seems to get used on a more frequent basis as HTML5 development has grown in popularity. It has, to some, become a keyword to define one of the key features of good HTML5 development. Regardless of how the term is used, at the end of the day when we refer to "responsive layouts" in web development, we are referring to the usage of modern web development techniques to enable the same page content to transition its layout and content within it to adjust for the users device and viewing resolution. In other words, making sure your page content is set up in an optimized manner for all viewing resolutions and is able to transition between any one of the layouts without the need for content of page refreshing.

CSS Media Queries

One of the most important assets when creating responsive layouts is the use of CSS Media Queries. Media Queries allow you to target specific CSS styles depending on your user's device, resolution, rotation, and more. Knowing as much as possible about the device and software loading your HTML documents will allow you to not only specify how specific devices and browsers are to display your content, but it can also allow your code to monitor real-time changes to the viewing methods as well. For instance, the following Media Query example changes the background color depending on device rotation:

@media screen and (orientation:portrait) {
  background-color: #FF0000;
}

@media screen and (orientation:landscape) {
  background-color: #0000FF;
}

The list of CSS Media Queries properties is short but it is important to understand what is available to you when creating your conditions. Therefore, let's quickly review what properties you have at your disposal when writing your Media Queries:

  • width: Describes the width of the targeted display area.
  • height: Describes the height of the targeted display area.
  • device-width: Describes the width of the rendering display of the output device.
  • device-height: Describes the height of the rendering display of the output device.
  • orientation: Is portrait when the value of the height media feature is greater than or equal to the value of the width media feature. Otherwise the orientation is landscape.
  • aspect-ratio: Defined as the ratio of the value of the width media feature to the value of the height media feature.
  • device-aspect-ratio: Defined as the ratio of the value of the device-width media feature to the value of the device-height media feature.
  • color: Describes the number of bits per color component of the output device. If the device is not a color device, the value is zero.
  • color-index: Describes the number of entries in the color look up table of the output device. If the device does not use a color look up table, the value is zero.
  • monochrome: Describes the number of bits per pixel in a monochrome frame buffer. If the device is not a monochrome device, the output device value will be 0.
  • resolution: Describes the resolution of the output device, that is, the density of the pixels. When querying devices with non-square pixels, in min-resolution queries the least-dense dimension must be compared to the specified value and in max-resolution queries the most-dense dimensions must be compared instead. A resolution (without a "min-" or "max-" prefix) query never matches a device with non-square pixels.
  • scan: Describes the scanning process of "tv" output devices.
  • grid: Used to query whether the output device is grid or bitmap. If the output device is grid-based (for example, a "tty" terminal, or a phone display with only one fixed font), the value will be 1. Otherwise, the value will be 0.
主站蜘蛛池模板: 介休市| 宜君县| 南漳县| 霍城县| 灌南县| 靖远县| 丰原市| 高雄市| 花莲市| 五指山市| 托里县| 类乌齐县| 巴楚县| 泾源县| 浪卡子县| 邻水| 利辛县| 东港市| 英吉沙县| 随州市| 同江市| 朝阳区| 云南省| 临邑县| 秭归县| 甘谷县| 建昌县| 东兰县| 怀来县| 兴业县| 潼关县| 南丰县| 邻水| 保德县| 天柱县| 镇宁| 穆棱市| 柳江县| 兴安盟| 社会| 吉水县|