利用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,539 Responses

  1. Профессиональный сервисный центр по ремонту источников бесперебойного питания.
    Мы предлагаем: сервис ибп
    Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!

  2. Greetings! I know this is kind of off topic but I was wondering which blog platform are you using for this website? I’m getting fed up of WordPress because I’ve had issues with hackers and I’m looking at options for another platform. I would be fantastic if you could point me in the direction of a good platform.

  3. Если вы искали где отремонтировать сломаную технику, обратите внимание – ремонт бытовой техники в новосибирск

  4. Профессиональный сервисный центр по ремонту Apple iPhone в Москве.
    Мы предлагаем: ремонт айфонов в москве недорого
    Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!

  5. bokep smp表示:

    Your style is really unique in comparison to other people I’ve read stuff from. Many thanks for posting when you’ve got the opportunity, Guess I’ll just bookmark this web site.

  6. I would like to show my thanks to you just for bailing me out of this problem. Right after researching through the world wide web and seeing strategies which are not helpful, I figured my entire life was gone. Existing minus the approaches to the issues you’ve fixed through your main guideline is a crucial case, and ones that would have in a negative way damaged my entire career if I hadn’t discovered your website. Your primary ability and kindness in playing with all things was precious. I am not sure what I would have done if I hadn’t come across such a solution like this. I’m able to at this moment look forward to my future. Thanks for your time very much for this impressive and result oriented guide. I won’t be reluctant to refer the sites to any person who should receive direction on this problem.

  7. bokep sma表示:

    Greetings! Very helpful advice in this particular article! It is the little changes that produce the biggest changes. Thanks for sharing!

  8. Earle表示:

    Also visit my web site – Daycare Near Me By State (Earle)

  9. Greetings! Very helpful advice within this article! It’s the little changes which will make the largest changes. Thanks a lot for sharing!

  10. Pokemon Cards表示:

    Your style is very unique compared to other folks I’ve read stuff from. Thank you for posting when you’ve got the opportunity, Guess I’ll just bookmark this web site.

  11. Если вы искали где отремонтировать сломаную технику, обратите внимание – тех профи

  12. Very usefull blog. i will follow this blog. keep up the good work.

  13. dry cleaners come in handy specially if you need your precious clothes to get cleaned very fast,

  14. vendorlist表示:

    Way cool! Some very valid points! I appreciate you writing this write-up and the rest of the website is extremely good.

  15. paglabas表示:

    Good day! I simply want to give you a huge thumbs up for your excellent information you have got here on this post. I’ll be returning to your site for more soon.

  16. paglabas表示:

    A fascinating discussion is worth comment. I do believe that you need to publish more about this topic, it may not be a taboo matter but usually people don’t talk about such topics. To the next! Many thanks!

  17. This is the right site for anybody who wishes to find out about this topic. You understand a whole lot its almost hard to argue with you (not that I actually will need to…HaHa). You definitely put a brand new spin on a topic that has been discussed for many years. Excellent stuff, just great.

  18. Oh my goodness! an incredible write-up dude. Many thanks Nevertheless My business is experiencing trouble with ur rss . Do not know why Cannot enroll in it. Perhaps there is anyone obtaining identical rss problem? Anyone who knows kindly respond. Thnkx

發佈留言

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