Skip to Content
MOBILE HTML5學習手冊
book

MOBILE HTML5學習手冊

by Estelle Weyl
June 2014
Intermediate to advanced
488 pages
9h 56m
Chinese
GoTop Information, Inc.
Content preview from MOBILE HTML5學習手冊
202
|
第七章
我們先建立一個媒體查詢清單物件,在媒體查詢清單物件中加入一個
addEventListener
監聽方法,它會呼叫一個函式來回應事件,並加入了一個函式來查看它是否符合媒體查
詢,並處理它。
我們可以移除監聽器:
myobj.removeEventListener('orientationchange', bodyOrientationClass);
CSS 最佳做法
為了維持你的網站品質並改善下載速度,以下有五個秘訣(或規則!)可以幫助你編寫
更佳的 CSS
1. 盡可能地減少 HTTP 請求
若要改善下載速度,請減少獨立的樣式表,以減少 HTTP 請求的數量。HTTP 請求可能
造成大量的額外負擔。減少請求的數量可以大幅度地減少網頁下載時間。
就下載時間而言,特別是在行動網路上,HTTP 請求通常是最耗費時間的因素。因此,
最好使用一長串的樣式表,裡面包含所有網站需要用到的樣式,而不要使用許多負責部
分網站的小型樣式表。
雖然在樣式表裡面將樣式模組化有一些好處,但是在上線時,請用一個較大的檔案來容
納每一個樣式“模組”,以傳遞所有的 CSS。請使用一個大的
all.css
來取代
style.css
home.css
about.css
footer.css
sidebar.css
等等。
比起讓用戶端下載多個網頁專用的樣式表,下載並緩存一個大型的 CSS 檔案通常會產生
比較好的使用者體驗,就算這些網頁專用的樣式表比較小。發出一個額外的 HTTP 請求
所浪費的成本,通常比幾行用不到的 CSS
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

JAVASCRIPT網頁應用程式設計

JAVASCRIPT網頁應用程式設計

Alex MacCaw

Publisher Resources

ISBN: 9789863471240