iPad CSS Layout with landscape / portrait orientation modes

http://matthewjamestaylor.com/blog/ipa ··· it-modes
Free iPad CSS layout with landscape/portrait orientation modes

The iPad has finally launched in Australia today, hooray! I will probably get one soon so I can continue to optimise my CSS layouts for as many devices as possible. But in the mean-time I will continue using the iPad emulator that comes with the iPhone SDK.

To celebrate the launch of the iPad I have built a special iPad optimised website layout that uses pure CSS to change layouts in the portrait and landscape orientation modes. The layout can be downloaded for free at the bottom of this article or from my iPad demo page. Here is a basic diagram of how the two orientations look:

iPad CSS layout portrait / landscape designs

In Landscape mode the layout is in two columns. The main content is in a wide left column and three side sections are stacked vertically in a narrow right column. When you rotate the iPad to the portrait orientation the layout changes to a single column design. In portrait mode the main content fills the full width of the screen and the three side content areas are positioned horizontally as three columns under the main content.

In both orientations there is a header at the top and a footer at the bottom. These both change in width from 1024 pixels wide in landscape, and 768 pixels wide in portrait. See my demo page for a more detailed diagram with pixel dimensions. Below are screenshots of my demo layout in the iPad emulator:

iPad CSS layout in the iPad emulator

How does it work?

The first thing I do is lock the layout's resolution to a 1:1 ratio so that each pixel exactly lines up with the pixels in the iPad's screen. I do this with the following META tag:

<meta name="viewport" content="width=768px, minimum-scale=1.0, maximum-scale=1.0" />

Locking the layout to a 1:1 ratio will prevent the zooming-in and out that normally occurs when the iPad is rotated (normally, landscape mode is more zoomed-in because the width of the webpage is displayed across 1024 pixels, as opposed to portrait mode when there are only 768 pixels available).

Next I combine this with some CSS rules that change the layout in portrait and landscape modes. I do this by writing all my landscape styles normally then overwriting some of them with the @media rule at the bottom of the CSS file when the device is in portrait mode. Here is a cut-down version of the CSS:

/*normal styles here */
#wrap {
width:1024px;
}
@media only screen and (orientation:portrait){
/* portrait styles here */
#wrap {
width:768px;
}
}

The method above works beautifully for changing the layout for the two orientations without JavaScript. Check out my iPad layout demo or download the demo files and try it for yourself.


Demo Download (ipad-css-layout.zip - 41kb)


I hope you enjoyed this post. If you are reading this on your brand new iPad then... lucky you! :)


크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2010/12/27 15:41 2010/12/27 15:41
,
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/5763

은평구유기동물보금자리 에서 우리집으로 분양 대기중인 "벼루"와 "루비" 입니다.
누가 벼루이고, 누가 루비일까요?
사용자 삽입 이미지사용자 삽입 이미지

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2010/12/27 13:35 2010/12/27 13:35
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/5762

비전과 동기부여

만일 당신이 배를 만들고 싶다면,
사람들을 불러 모아 목재를 가져오게 하고 일을 지시하고
일감을 나눠주는 등의 일을 하지 마라.
대신 그들에게 저 넓고 끝없는 바다에 대한 동경심을 키워줘라.
(If you want to build a ship,
don't drum up the men to gather wood,
divide the work and give orders.
Instead, teach them to yearn for the vast and endless sea.)
- 생텍쥐페리(Antoine Marie Roger De Saint Exupéry)

비전이야말로 조직원들을 동기부여시키는
가장 핵심적인 것임을 알 수 있습니다.
비전, 하고 싶은 일, 같이 일하고 싶은 직장 동료,
자기 계발 등이 급여나 복리 후생 등보다
훨씬 더 큰 동기부여요인임을
경영자들이 빨리 깨달아야 하겠습니다.

Vision is the most important element for motivating workers.
Businessmen must realize that vision;
working on something you enjoy with the people you want to work
with are far greater motivating factors than money or welfare.
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2010/12/27 10:00 2010/12/27 10:00
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/5761

'당신은 미쳐야 합니다'

당신은 미쳐야 합니다.
미치려면 이유가 있어야 합니다.
'미쳤다'라고 말할 때도 분명한 이유가 있어야 합니다.
이것은 정신병이 들었다는 말이 아니라,
자기가 옳다고 하는 일에 몰입하는 것을 말합니다.
이것 밖에 다른 길이 없다고 생각하고
자신의 생명을 거는 것을 말합니다.
가슴에 있는 불을 아무도 끌 수 없는
사람이 된다는 것을 말합니다.
저는 미친 사람이고,
여러분은 안 미친
사람이에요.


- 옥한흠의《광인》중에서 -


* 당신은 미쳐야 합니다.
좋은 일에 제대로 미쳐야 합니다.
아무나 제대로 미친 사람이 될 수 없습니다.
꿈이 있는 사람, 그 너머에 꿈너머꿈이 있는 사람,
그걸 생각하면 가슴이 뛰는 사람만 미칠 수 있습니다.
미친 사람만 새 길을 낼 수 있습니다.
좋은 길을 새로 낼 수 있습니다.
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 홍반장

2010/12/27 09:59 2010/12/27 09:59
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/5760


블로그 이미지

- 홍반장

Archives

Recent Trackbacks

Calendar

«   2010/12   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Statistics Graph

Site Stats

Total hits:
187970
Today:
156
Yesterday:
614