利用Dreamweaver CS5.5設計行動裝置網頁

智慧型手機竄紅、平板電腦普及、行動網路發達,讓上網不再是只需要宅在家裡才能做到的事情,不管是走路、等車、坐車、吃飯、蹲馬桶以及許多的時候,都可以利用這些裝置來進入網際網路的花花世界,所以許多的網站也針對這些行動裝置來製作獨立的頁面,甚至根據螢幕尺寸來最佳化頁面。

iPhone 臉書網站直式
iPhone 臉書網站橫式

上面這兩張圖,就是Facebook為了行動裝置而製作的頁面,左邊是iPhone直拿觀賞,右手邊則是橫拿,可以看到在左邊最上排只看到「個人檔案、訊息、更多」,右邊可看到「個人檔案、訊息、朋友、相片、更多」,橫拿比直拿多出了兩個選項,雖然只是小地方,但設計就是要掌握每一個細節,那我們該如何設計這樣的網頁呢?就讓我們慢慢來體驗吧!

很久很久以前在製作網頁的時候,我們可以在同一個頁面使用不同媒體的CSS樣式表來控制顯示內容,例如:

<link href="css/screen.css" rel="stylesheet" type="text/css" media="screen" />
<link href="css/handheld.css" rel="stylesheet" type="text/css" media="handheld" />
<link href="css/print.css" rel="stylesheet" type="text/css" media="print" />

上面的第一行是代表螢幕樣式、第二行為行動裝置樣式、第三行為列印樣式,不過目前有關行動裝置樣式已經因為時代的演進與科技的發達,已經瀕臨淘汰的邊緣了,現在我們製作行動裝置樣式,主要是靠裝置的螢幕寬度來決定不同的樣式表。

在Dreamweaver CS5.5中除了提供多螢幕預覽的模式之外:

Dreamweaver CS5.5 多螢幕預覽
Dreamweaver CS5.5 多螢幕預覽介面

還可以針對不同的螢幕尺寸來設定該使用哪個CSS樣式表檔,只要按下多螢幕預覽上方的媒體查詢按鈕。

Dreamweaver CS5.5 媒體查詢

上面的範例是針對螢幕寬度小於320像素的裝置使用phone.css,螢幕尺寸介於321像素~768像素之間的裝置使用tablet.css,加入了這樣的設定後在頁面內會多出兩段CSS的連結語法:

<link href="css/phone.css" rel="stylesheet" type="text/css" media="only screen and (max-width:320px)" />
<link href="css/tablet.css" rel="stylesheet" type="text/css" media="only screen and (min-width:321px) and (max-width:768px)" />

當然要看你在這兩個CSS中如何設定呈現頁面樣式囉!我的範例是在phone.css裡面將景點圖片的display設為none,另外要注意在<head></head>區段中要加入以下的語法:

<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">

否則在手機橫向後頁面將會被放大,這樣我們的樣式表就會失效,瀏覽的效果可以參考下面的影片:

可以看到在320像素以下景點圖片會被隱藏,而超過這個大小圖片就會自動顯示,大家也可以自行用行動裝置瀏覽這個網址,也準備這個範例的原始檔讓大家下載研究。

You may also like...

6,625 Responses

  1. Youre so cool! I dont suppose Ive read like this before. So nice to find somebody by incorporating authentic applying for grants this subject. realy thanks for starting this up. this site is a thing that’s needed on the web, somebody after some bit originality. helpful problem for bringing something new on the web!

  2. Néanmois, merci quant à la pureté des sujet mentionnés maintenant : on sait aujourd’hui s”interviewer sur la véritable signification de certains des arguments que vous déférez ci…

  3. Whats up. Very cool web site!! Man .. Beautiful .. Superb .. I’ll bookmark your site and take the feeds additionally…I am glad to find so much helpful info here within the article. Thanks for sharing.

  4. Wonderful goods from you, man. I’ve understand your stuff previous to and you are just extremely fantastic. I really like what you have acquired here, certainly like what you are saying and the way in which you say it. You make it entertaining and you still take care of to keep it smart. I cant wait to read much more from you. This is really a terrific web site.

  5. I am looking for and I enjoy post a comment of the fact that content with the post rocks ! Great work

  6. I can’t really help but admire your blog, your blog is so adorable and nice ,   

  7. This is a lot of information to take in, but I am enjoying the thought process. I really am impressed with your article. Thank you.

  8. An impressive share, I recently given this onto a colleague who was conducting a little analysis during this. And hubby the truth is bought me breakfast due to the fact I found it for him.. smile. So well then, i’ll reword that: Thnx for your treat! But yeah Thnkx for spending some time go over this, I’m strongly regarding it and really like reading regarding this topic. If you can, as you grow expertise, would you mind updating your website with more details? It can be highly helpful for me. Huge thumb up due to this blog post!

  9. Heya i am for the first time here. I came across this board and I in finding It really helpful & it helped me out much. I hope to present something again and help others such as you aided me.

  10. Hi, you used to write magnificent articles about seattle plumbers, but the last several posts have been kinda lackluster… I miss your tremendous articles. Past several posts are just a little out of track! Seattle Plumbing

  11. Mal was ganz anderes. Was galubt ihr, wer wird die WM der Frauen gewinnen? Ich hoffe England. lol.

  12. When i open the Give food to it provides me with many different garbled text, may be the concern on my small end?

  13. Hi, I would like to subscribe for this webpage to
    take latest updates, therefore where can i do it please help out.

  14. Hey, I just hopped over to your site by way of StumbleUpon. Now not one thing I would normally read, however I appreciated your thoughts none the less. Thanks for making something worth reading.

  15. Hi there, just became alert to your blog through Google, and found that it is really informative. I am gonna watch out for brussels. I¡¦ll be grateful if you continue this in future. Numerous people will be benefited from your writing. Cheers!

  16. *Nice post. I learn something more challenging on different blogs everyday. It will always be stimulating to read content from other writers and practice a little something from their store. I’d prefer to use some with the content on my blog whether you don’t mind. Natually I’ll give you a link on your web blog. Thanks for sharing.

  17. Rlndwb表示:

    hydrea online order – hydroxyurea medication buy robaxin cheap

  18. Ten post był bardzo pomocny w zrozumieniu zawiłości SEO.

  19. Dzięki za kompleksowy przewodnik po SEO. Bardzo pouczający!

  20. Ten post to świetne źródło informacji dla każdego, kto potrzebuje SEO.

  21. Ten blog to cenne źródło informacji dla każdego, kto myśli o SEO.

  22. Ten post to świetne źródło informacji dla każdego, kto potrzebuje SEO.

  23. Dzięki za kompleksowy przewodnik po SEO. Bardzo pouczający!

  24. tubidy mp3表示:

    Oh my goodness! Awesome article dude! Thank you, However I am going through troubles with your RSS. I don’t understand the reason why I am unable to join it. Is there anyone else getting similar RSS issues? Anyone who knows the answer will you kindly respond? Thanx!

  25. That song sucks i think, my younger brother is listening that, and its so boring song !

  26. You should be a part of a contest for one of the highest quality websites on the web. I will recommend this web site!

  27. I was recommended this website by my cousin. I am not sure whether this post is written by him as nobody else know such detailed about my trouble. You’re wonderful! Thanks!

  28. Spot lets start on this write-up, I truly think this fabulous website requirements considerably more consideration. I’ll apt to be again to see additional, thank you for that information.

  29. The digital cigarette uses a battery and a small heating aspect the vaporize the e-liquid. This vapor can then be inhaled and exhaled

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。