字體:小 中 大 |
|
|
||
| 2013/05/13 13:49:30瀏覽341|回應0|推薦1 | ||
Theme building is at the heart of WordPress. It’s the technique you use to build bespoke websites for yourself or your clients and it’s a vital skill for anyone wanting to design and develop with WordPress. More and more WordPress themes now are responsive – they use CSS media queries to adapt to different screen widths, adjusting the layout and making design and interface changes to make any site created using the theme easier to read and interact with on a range of devices and screen sizes. In this tutorial I’m going to show you how to build a Mobile First WordPress theme, which starts with the styling for the smallest screens and works upwards. What You’ll Need for This TutorialIn this tutorial I’m going to take a WordPress theme with minimal styling and then style it to make it mobile first. The eventual design will be very simple – the idea is to cover the building blocks of the content and layout and you can add your own design goodies afterwards if you want. To follow the steps in this tutorial you’ll need the following:
I’m assuming that you’re already familiar with installing and working with WordPress. I’ll work on a remote WordPress installation Unless you have your own theme you’re working on, you’ll also need the starting code for the tutorial. You can see my theme at http://rachelmccollin.co.uk/nettuts-wpresponsive-tutorial/ and download the code for the theme at various stages of its development from xxx [to be added based on nettuts+ downloads system]. Before We Start: What’s Mobile First?Mobile First is a term which was first coined by Luke Wroblewski. It refers to the
1. Our Starting ThemeThe starting theme has minimal styling applied to it, and no layout styling at all yet – that will be added as we work through the tutorial. The elements which the theme includes are shown below: At present, the theme looks like this on a smartphone (i.e. at 320 x 480px screen size): As I haven’t applied any widths yet, the site should resize to smaller screens – but it doesn’t because the smartphone is displaying it as if it were 960px wide. The first thing to do is tell smartphones to display the site at the actual width of the screen. 2. Setting the Screen WidthTo tell smartphones to behave nicely with regard to screen width, I add a line into the
This instructs smartphones to display the page at the device’s screen width rather than create a virtual 960px wide viewport which is the default behaviour. Now the theme looks like this on a small screen: If you’ve created responsive stylesheets before but not Mobile First ones, this will be a bit of a revelation. Remember all that extra styling you added to your media queries for small screens? You’ll need very little of it, as a page with minimal layout styling already looks better on mobile than it does on the desktop, as you can see from this screenshot, taken at 1024px wide: But I still need to add some layout styling for small screens, which is the next step. |
||
| ( 知識學習|隨堂筆記 ) |














