利用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...

5,343 Responses

  1. porn表示:

    I really love your blog.. Very nice colors & theme. Did you develop this amazing site yourself? Please reply back as I’m attempting to create my very own website and want to find out where you got this from or exactly what the theme is called. Cheers!

  2. 술먹고 비아그라 먹으면

    음주 후 비아그라 복용하는 것은 권장되지 않습니다

  3. 약국에서 비아그라 파나요
    비아그라 판매 이해하기: 지역 약국에서 구입할 수 있습니까?

  4. Having read this I thought it was really informative. I appreciate you taking the time and energy to put this article together. I once again find myself spending way too much time both reading and leaving comments. But so what, it was still worthwhile.

  5. 비아그라 자주 먹으면

    비아그라를 정기적으로 복용할 경우 나타나는 증상

  6. 30대 비아그라
    30대 비아그라로 성 경험 극대화: 복용량 및 타이밍 요령

  7. Tlgkzg表示:

    order lasuna pills – purchase lasuna for sale where to buy himcolin without a prescription

  8. Card game表示:

    Hi there! This article could not be written much better! Going through this article reminds me of my previous roommate! He continually kept talking about this. I am going to send this information to him. Fairly certain he’ll have a good read. Thank you for sharing!

  9. AI for Kids表示:

    An interesting discussion is worth comment. There’s no doubt that that you ought to publish more on this subject, it might not be a taboo matter but typically people don’t talk about these topics. To the next! Many thanks.

  10. 비아그라를 활용하여 성적 기능을 개선하기 위한 전략은 다음과 같습니다. 비아그라는 발기부전 치료에 사용되는 약물로, 적절한 사용법과 함께 다양한 전략을 통해 성적 기능을 향상시킬 수 있습니다.

  11. hishypesports表示:

    I want to to thank you for this good read!! I absolutely enjoyed every little bit of it. I’ve got you book-marked to look at new things you post…

  12. 여러번 하는 법
    여러번 하는 법: 몇가지 자세한 가이드

  13. Hi there! This blog post could not be written any better! Looking through this post reminds me of my previous roommate! He continually kept talking about this. I’ll forward this information to him. Fairly certain he will have a good read. Thank you for sharing!

  14. iwin表示:

    Hello there! I could have sworn I’ve been to this web site before but after browsing through a few of the posts I realized it’s new to me. Anyways, I’m certainly happy I discovered it and I’ll be bookmarking it and checking back frequently!

  15. link bokep表示:

    I’d like to thank you for the efforts you’ve put in writing this blog. I’m hoping to check out the same high-grade blog posts from you in the future as well. In truth, your creative writing abilities has motivated me to get my own website now 😉

  16. porn表示:

    There is certainly a lot to find out about this topic. I really like all of the points you made.

  17. memek表示:

    I love looking through an article that will make men and women think. Also, thanks for permitting me to comment.

  18. memek表示:

    Good post. I will be dealing with some of these issues as well..

發佈留言

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