Anonymous
Not logged in
Talk
Contributions
Create account
Log in
Publication Station
Search
Editing
Responsive webdesign basics
From Publication Station
Namespaces
Page
Discussion
More
More
Page actions
Read
Edit
History
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== 1. Tell the browser not to scale === By default, smartphone browsers assume that a website will not be responsive, and will therefore display your website completely zoomed out. This is basically never what you want. Therefore, always set the viewport meta tag in the head of your document to tell the browser not to scale. <code><meta name="viewport" content="width=device-width, initial-scale=1" /></code> === 2. Make sure your whole website is flexible === There is an infinite amount of screen sizes out there. Even for laptop screens, one screen can be twice the size of another. Therefore, it is always important that your website layout is flexible. The easiest way to achieve this is to '''never use pixels to set the size or position of elements'''. Instead, you should always use % or VW and VH. Of course, this is easier said than done and there are exceptions to this rule. One thing to keep in mind is that sometimes you need to limit the line length in text, this can be done by setting the max width of your paragraphs. === 3. Add breakpoints === There is a limit to how flexible your layout can be. For example, a three-column layout will look great on many desktop screens will simply not fit on a phone screen. Therefore you should test what the size limit of your specific design is, and from that limit, the layout should change. This can be done with CSS media queries. To illustrate, the CSS below will create a three-column layout by default, but as soon as the user's screen is smaller than 500px, the layout will change to a single column:<syntaxhighlight lang="css" line="1"> article{ column-count:3; } @media (max-width: 500px) { article{ column-count:1; } } </syntaxhighlight>Many things can be added in this media query. Elements can be hidden on smaller screens, menus switched to dropdown menus, font-sizes can be changed and margins made smaller. You can also add multiple media queries, so that you can optimize for multiple screen sizes. This complicates the CSS quite a but, so usually just two or three media queries should suffice. === Advanced Responsive Design === A Wiki article that goes into more detail on this subject can be found [[Responsive design|here]].
Summary:
Please note that all contributions to Publication Station are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Publication Station:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation
Main navigation
Main page
Printmaking Studio
Print Studio
Dig. Publishing Studio
Namespaces
Grafiwiki
Random Page
Log in
Wiki tools
Wiki tools
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs