Making My WordPress Blog Mobile-Friendly with a Responsive CSS Framework
Translated from the Korean original. Read the original →

I recently tweaked my CSS so the blog works better on mobile devices with all kinds of screen sizes. For the three days before this, the site used a plugin called WPtouch to serve a separate "responsive" mobile page, but it caused quite a few problems. That, plus a lot of inspiration from mathskykite's blog, is how I ended up here. It's not completely finished yet, but after a lot of manual trial and error, the design and font size now change with the width of the window, as you can see below. Up to a certain width I wanted to show the whole page as much as possible, so nothing changes at first. Once the window gets fairly narrow, the sidebar and the footer disappear. After that, the font size, the layout and the comment box gradually adjust.
But why did the recording come out in such poor quality... T_T
The code is a modified version of what originally came with the Twenty Eleven theme. Here are the first four steps:
@media (max-width: 776px) {
#page{clear:both; max-width:600px; !important; padding:0; !important; margin:auto; overflow:hidden;}
#primary{max-width:600px; padding:0; margin:0}
#banners2 {display:none;}
#secondary {display: none;}
#main #content {max-width: 560px;margin: 0 0px 0 15px;padding: 0;}
.commentlist {width: 100%;}
.commentlist > li.comment,
.commentlist .pingback {margin-left: 50px;width: auto;}
}
@media (max-width: 626px) {
#page{max-width:550px;}
#primary{max-width:550px;}
#main #content {max-width: 510px;margin: 0 0 0 20px;}
}
@media (max-width: 573px) {
#page{max-width:500px;}
#primary{max-width:500px;}
#main #content {max-width: 460px;}
body, input, textarea {font-size: 12px;}
#site-title {padding:10px 0}
#site-title a {font-size: 24px;}
#site-description {font-size: 12px;}
#access ul {font-size: 12px;}
.featured-post .entry-title {font-size: 14px; display:inline}
.entry-meta {font-size: 12px; display:block}
blockquote {margin: 0; display:inline}
blockquote.pull {font-size: 14px; display:inline}
}
@media (max-width: 523px) {
#page{max-width:490px;}
#primary{max-width:490px;}
#main #content {max-width: 450px;}
/* Talking avatars take up too much room at this size */
.commentlist > li.comment,
.commentlist > li.pingback {margin-left: -48px !important;}
.commentlist .avatar {background: transparent;display: block;padding: 0; position: static;}
/* Use the available space in the smaller comment form */
#respond input[type="text"] {width: 95%;}
#respond .comment-form-author .required,
#respond .comment-form-email .required {left: 95%;}
#content .gallery-columns-3 .gallery-item {width: 31%;padding-right: 2%;}
#content .gallery-columns-3 .gallery-item img {width: 100%;height: auto;}
}

Here's why I dropped the "responsive" approach (detecting mobile devices and switching to a whole different design) and went with a CSS framework instead:
1. With a CSS framework, you don't need any special settings. You can keep your site's design and features exactly as they are and still serve it to mobile devices of every screen size.
2. A "responsive" setup that detects devices can't accurately catch every mobile user agent out there, and there are already more than 70 different screen sizes. With the iPhone series, for example, you only need to match "iPhone" in the user agent. But Samsung's Galaxy phones come in so many models, with different model numbers in each country, that you have to list around 50 model names. And the bigger problem is that these aren't the only two phone makers.
3. It's hard to handle the many "in-between" screen sizes that fall somewhere between a smartphone and a PC, like the iPad. If there were only three screen sizes (PC, iPad and phone), you could just build three separate versions. But the number of screen sizes is only going to explode from here, so a CSS framework really is the best choice.
4. With the device-detection approach, you have to go back and fix the site every time a new device or screen size comes out, which is a hassle.
That said, I'm still new to CSS, so there's a lot of fine-tuning left to do, including the plugins. Sigh.
Comments 3
헤헤헤, 이렇게 점점 웹프로그래밍(?)의 세계에 발을 들이시는군요. 좋은 일입니다. 저도 요즘 이런 걸 배워보고 싶어서 종종 웹을 뒤져보고 있지요.
... 물론 제 제1 목표는 자바스크립트로 구현되고 근대적인 풀이법이 탑재된 스도쿠 풀이 검색 알고리즘이지만요 -ㅁ-;; (파이썬으로 옮겨볼까 하다가 그냥 익숙한 언어로 회귀...)
파이썬 짱짱맨!!
sos440님 오랜만입니다! 이곳까지 먼 길(?) 와 주셔서 감사하네요. 요즘 이것저것 건드리는 맛으로 시간가는 줄 모르겠네요. 그러다 보면 어느새 날은 밝아있고.. 하..공부해야 되는데 OTL 그나저나 스도쿠 알고리즘 기대하고 있겠습니다!