April 17, 201412 yr Hello all!I've been trying to design a website for a couple of weeks now and it's been really stressful wanting to learn everything about html/5 and css/3 (I've just started learning), and I'm being pretty impatient.What I've done is built a basic HTML5 structure with a navigation inside a header, you lose sight of the header/nav as you scroll down.What I would like which I've failed at is an interface compatible with all browsers and devices, a design that adjusts to the users browser size not matter what browser/device. Which also allows zooming in on smaller devices like tablets/iPhones etc. Every aspect of the site needs to be fixed in place (at the moment my navigation moves up and down when I'm resizing the browser) where the user can move around and zoom in and out.I've also read into the benefits of em, so I set the default font to 100%, and all the headers/paragraphs etc I set to em accordingly. Would it be wise to set all fonts to em and the rest of my website like margins etc to percentages?Thanks for the help in advance!
April 18, 201412 yr research responsive design. For fonts this is what I do. I set up a base percentage in the html element: html { font-size: 62.5%; @media screen and (max-width: 900px) { font-size: 60%; } @media screen and (max-width: 768px) { font-size: 56%; } @media screen and (max-width: 480px) { font-size: 52%; } } This allows the font's to scale down as the window size reduces. Now the reason I go with 62.5% for the base font size is for easy conversion between REM and PX sizes (REM doesn't work in IE8 so it needs a px fallback. Then you set the font sizes on the selected elements to scale from the % font sizes above: h1 { font-size: 30px; font-size: 3rem; } h2 { font-size: 25px; font-size: 2.5rem }
April 18, 201412 yr Use % for your elements and margins that'll make your layout flexible , and read about media-queries to make your layout look good on all screen sizes
April 18, 201412 yr Author Interesting info on the font there I'll definitely do it. Though is there not a way for the page to automatically change dimensions?
April 18, 201412 yr Remember to disable the zoom-out which is default on most handheld devices. You do this by adding a viewport meta-tag to your document: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> If you need to mix % and pixels in your css for widths, margin and padding it might also be a good idea to use border box-sizing on your elements: #leftDiv, #rightDiv{ box-sizing:border-box; } That will prevent your elements from breaking out of the grid at all resolutions. Edited April 18, 201412 yr by Nillervision
April 18, 201412 yr Yes, like Nillervision said, you need to change the box model using the box-sizing property, this makes it a lot easier to work with % based designs. I the grids I design like this: Based on a 12 column grid with a 10px gutter. The gutter width should be in pixels and not % in a responsive design. .row { /* set the negative margins equal to the gutter width that will stop the outermost columns being pushed in. */ ; margin: 0 -10px; } .row:before { /* clearfix */ display: table; clear: both; content: " "; } [class^="col-"] { float: left; padding-left: 10px; padding-right: 10px; } .col-8 { width: 66.666%; } .col-6 { width: 50%; } .col-4 { width: 33.333%; } Edited April 18, 201412 yr by rbrtsmith
April 18, 201412 yr Author Sorry but why disable zoom-out if users need it on smaller devices? I want the user to be able to move around, zoom in and out. Thanks for the border box sizing tip, thats something I needed as my nav bar was collapsing..
April 18, 201412 yr That doesn't disable the users ability to zoom in on the screen. You need the meta tag in order for your responsive design to be correctly displayed in the device (the initial scale value that is). Edited April 18, 201412 yr by rbrtsmith
April 18, 201412 yr Sorry but why disable zoom-out if users need it on smaller devices? I want the user to be able to move around, zoom in and out. Thanks for the border box sizing tip, thats something I needed as my nav bar was collapsing.. While there are arguments for both, one could argue that you wouldn't need to have the user zoom if the layout was done correctly. Just one side of the argument. Just depends on your site and how you want it to act. I typically disable it.
April 18, 201412 yr Author Ah i see, I just don't want to make it too complex. Just so when the user clicks on the site it is displayed as 100% then they just zoom in and move around etc to perform tasks. The majority of users will be connecting to the site from home i.e laptop/pc Thanks for the help people, probably have all the info I now need to start working on the site tonight.. Edited April 18, 201412 yr by legg92
April 18, 201412 yr You shouldn't need to zoom in the view the content, a well designed responsive site will never require the user to scroll left or right, the whole point of architecting the layout based on percentages is that it will always adapt to the width of the screen. Look at the UI you get on native Iphone apps, this is the kind of layout you should get with a good responsive website when viewed on a mobile device. Edited April 18, 201412 yr by rbrtsmith
Create an account or sign in to comment