Responsive Web Design Techniques

Don’t see what that even has to do with their garbage – ooh look, he’s using a elastic max-width; so innovative, different and belongs specifically to one framework.

RIGHT.

Because of course I’ve not been declaring:


min-width:752px;
max-width:68em;
width:95%;

on websites since long before we could even USE media queries… much less long before you ever posted a link to a framework I’d never even heard of before this thread.

RIGHT.

Oh yes, I got 'for a bigger screen declare a bigger width" from them… Of course I did.

For those of you from outside New England, this is called sarcasm. I can’t actually respond properly without getting banned.

@SegaThat’s scalable, that’s not responsive.

You’re starting in the right place: fluid, elastic layouts. Relative dimensions, min-width, max-width. But there’s more.

<hr>

I believe this is an example explaining the turning point with responsive design: statically making an element float it’s not responsive design. Dynamically unfloating the element is. Static equals CSS without media queries. Dynamic equals CSS with media queries.

So responsive design equals dynamic CSS code, not relative values for CSS properties.

<hr>

Because a scaled down website, made with bigger screens in mind, however elastic it may be it’s still unreadable on a much smaller screen, you add media queries, where you change things in your layout, based on your interrogation (query) of the user’s device (media): drop from two columns to one, change the font size for headings or other elements, and also remove or add certain design elements.

Most responsive design adopters will tell you this: go mobile first. You start by creating a basic mobile version of your site and then you enhance it as you go up the screen size: tablets, netbooks, notebooks, laptops, desktops. Techniques may vary, and there are also those that go from up way down. But they all use media queries to first find out the user’s media parameters and respond accordingly: responsive design.

I don’t know if they got that from you, using em for container size, I very much doubt that, but my point was that they use at least one thing the same as you do, so it’s not all bad, even when seen through your eyes.

I’m in the middle on that… kind of…

What I start with first is semantic layout and plain design for CSS off… hence by use of proper heading orders, horizontal rules for content breaks where a section would lack a header or it would be inappropriate, etc, etc…

The mobile first folks are basically bending over backwards to support handhelds that never worked right online in the first place – waste of time and effort. Media queries let us target modern handhelds, most older handhelds have had to deal with desktop code all along, and tend to mangle anything you try to send them for layout so badly it’s usually not even worth the effort of trying to target them (blazer comes to mind); what with the dozens of different phone browsers NONE of which handle the same code the same way.

If you start in the middle – basically what you send IE8/lower who don’t know media queries; then add code to expand it up for larger displays on modern browsers, and code to shrink it down for modern handhelds – it will gracefully degrade in a useful/non-annoying manner for IE8-, who are still large enough a crowd you shouldn’t be pissing them off sending them the mobile version of your site.

At least, that’s how I’m looking at it. It comes down to which layout do you want to send when media queries fail – the majority of people for whom that’s going to fail, can probably handle a 800 friendly layout, and will probably NOT be impressed if you send them a single column mobile page.

It also seems easier when dealing with media queries to remove properties, layout and content than it is to add them.

Though I suppose that comes down to if you are a ‘responsive adopter’, or someone who sees this as nothing new. and just a natural progression

Probably why I’m not a big fan of it even having this new name… but then I HATE new names for old ideas.

@ralph.m
Many thanks for the script.

@deathshadow60,

http://www.cutcodedown.com/codeExamples/fluidDemo/template.html

Many thanks for the fleshed out working example. I have been looking quite some time for a new skin and yours seems ideal. I look forward to adding the content.

On my localhost version I added some colours, still cannot fathom out what is happening and would be grateful for an explanation.

@itmitică;

would it be possible to give the most basic example of responsive web design. I am more interested in something very basic to grasp it’s concepts. The frameworks out there have javascript to them, so is this something we need?

Rachel Andrew’s doing something fun with responsive design that doesn’t involve bloated stylesheets or grids. The code archive for [URL=“http://www.sitepoint.com/books/cssant4/”]her book contains some interesting samples in Chapter 9.

@Sega

Javascript only use is to fix things otherwise impossible to fix by CSS. It’s not something you’d rely on for the important stuff, it’s more something like the last resort.

A basic example.

Let’s start from a layout like you do now: main content as a column, nav floated left. In this case, you have a version with main content and nav side by side, that may look good on bigger screens, but on smaller screens you’ll have an unreadable scalled down version of them side by side.

When you add a media query like this to your old CSS:


@media screen and (max-width:480px)
{
	#nav
	{
		float: none;
	}
}

on smaller screens you’ll now have a different version for your layout, where the main content occupy the whole screen, it doesn’t share it with the nav element. As such, the readability may increase.

<hr>

Now, for a different approach.

You forget about making sites the old way.

You start mobile first: less strain on the mobile devices and their smaller bandwidths: a basic layout.

No JS slides for mobile. You cut down the number of graphic elements. An easier to use nav.

The next steps: tablets through desktops. You start adding graphic elements, JS slides, start floating elements to add columns.

Now, for a different approach.

You forget about making sites the old way.

You start mobile first: less strain on the mobile devices and their smaller bandwidths: a basic layout.

No JS slides for mobile. You cut down the number of graphic elements. An easier to use nav.

The next steps: tablets through desktops. You start adding graphic elements, JS slides, start floating elements to add columns.

I disagree with the “mobile first” approach.

Instead of starting with mobile, and adding more things for bigger screens, why not design the site to be fast and light on every device? Why do we assume that mobile users want a super-fast, stripped-down version of the site, but desktop users want all kinds of extra bloated stuff?

My desktop is an ancient Dell, dual-booting Windows XP and Ubuntu. My smart phone is more powerful in every way than my desktop, and the 4GLTE signal on my phone is faster than my home cable connection. Sliders, JQuery effects, and things like that work better on my phone! And I particularly don’t like the idea that I am getting a lesser version of the site, and missing some content, when browsing on my phone.

How about no sliders (or any other unnecessary JS/JQuery stuff) at all? (Unless you have clients that absolutely have to have them, like some of mine, heh.) Why not easier to use navigation menus on every device?

There’s no way to add extra stuff for bigger screens and not have the mobiles download it anyway, without using JS or server-side scripting. And then you run into a lot of other issues trying to do that. And having mobiles download stuff and not showing it is the worst of both worlds.

Starting with mobile first also adds the problem of browsers that can’t understand media queries - IE8 - getting the mobile version unless you use respond.js or something - more unnecessary JS, in my opinion.

Every site I design is responsive. Instead of going “mobile first”, I design every site for IE8 first, knowing that it will be visited on crappy connections, or with an ancient computer like mine. I only use media queries to change the layout - going from 2 or 3 columns to one, adjusting some font sizes, and changing the way the nav menu appears - without removing or adding any content (except for a few very small things). Then use TinySrc or another image swapping technique to send smaller image files to smaller screens, if I have to use large images.

That’s it. No grid systems, no unnecessary bloat.

BINGO!!! You go on to mention all the things that IMHO have no *** business on a website in the first place! Stupid scripted animated crap that turns websites into slow buggy broken disasters.

I don’t necessarily disagree, but I dislike the approach you take, with false arguments. Why do you automatically assume “extra bloated stuff”?

Your experience alone is not a standard which you’d force on your clients and users. That’s a narrow view, counter productive approach.

How about less “my way is the way”? If others want those things, it’s their choice. Who are you to try and decide for everyone?

I tend to agree with you here.

I tend to agree with you here as well.

It’s a far fetch, you “knowing” so many “precise” things about your visitors as well as, again, the “unnecessary bloat” you don’t even know what it may actually be, but you are quick to label it so. Completely far fetched.

<hr>

You have a system. If it were so good, everybody would be quick to adopt it. Instead, it’s just a system amongst many others. It pays to know them all.

A project may require an approach, another project a completely different approach. Knowing more than one system helps that.

It doesn’t make sense to automatically dismiss one system or the other. Or to slander by implying about things you don’t even know what they may be.

That’s false generalisation for the sake of strong beligerant purposes. It’s a narrow false view and without real proof and fundament.

You don’t like some stuff? I’m pretty sure some will look at your designs and believe they’re so bad they won’t even take them seriosly. And they may actually give you reasons you may not like. That’s real world: everyone can make choices, it’s not someone deciding they have the best solution that fits everyone.

[QUOTE=itmitică;5098634]I don’t necessarily disagree, but I dislike the approach you take, with false arguments. Why do you automatically assume “extra bloated stuff”?[/quote]Most likely b/c he sees it all over the web…but wait…that’s only him…obviously not trustable.

Your experience alone is not a standard which you’d force on your clients and users. That’s a narrow view, counter productive approach.

Would you have him testify as to what you experience, instead? Or just not share his opinion at all? I’m sure he wants to apologize for adding to the conversation.

How about less “my way is the way”? If others want those things, it’s their choice. Who are you to try and decide for everyone?
How ironic…

<hr>
Nice HTML4! Wait…what are you trying to do?

Or to slander by implying about things you don’t even know what they may be.
If you could share how you slander about things that you don’t even know about, I’d be very impressed and very interested to hear. Mind sharing?

~TehYoyo

I have to agree with itmitca here. I’m not saying content should be cut out for mobile users, but most of the design details should be stripped out, ads, etc. Just give them navigation and content, perhaps a logo too just to identify it as your site.

I know when I go to mobile sites, I hate navigating through everything on the real site. I do believe mobile should be stripped down a bit.

Okay, first of all, I wasn’t attacking your post personally, only challenging the idea that mobile users are somehow special and get light-weight, fast sites, while desktop users get all kinds of extras.

Sliding image galleries, JQuery effects, animations, huge graphics… those kinds of things are extras. They aren’t really needed. Yeah, they look nice sometimes, but a well-designed site can achieve its purpose (and look great!) without using them.

No, I’m not saying never ever use them. Sometimes, used sparingly, they can enhance a site. But I have seen very few sites that use those things sparingly. Mostly, it seems to be “Let’s just throw everything in here because it looks cool” or “It all came with the WordPress theme so we’re gonna use it, and even the stuff we’re not using on our site gets downloaded, too, but who cares? Yay.”

Your experience alone is not a standard which you’d force on your clients and users. That’s a narrow view, counter productive approach.

Only using my experience as an example that mobile users are not necessarily less limited with their devices than desktops and that mobile users don’t necessarily want a lesser experience than desktop users.

How about less “my way is the way”? If others want those things, it’s their choice. Who are you to try and decide for everyone?

I’m not. Designers who decide to strip content and features from sites for mobile users are the ones who making choices for their users.

It’s not a great idea to assume that mobile users have different needs than desktop users - that mobile users are “on the go” or are “in a hurry” and other such things I see tossed around to justify giving mobile users a stripped version of the site. People browse from their mobiles in all sorts of different situations. (And I know many people who have no home computer and their only internet access is with mobile phones or tablets, so what about them?)

It’s a far fetch, you “knowing” so many “precise” things about your visitors as well as, again, the “unnecessary bloat” you don’t even know what it may actually be, but you are quick to label it so. Completely far fetched.

If by saying I know users will be visiting the site on slow connections and crappy computers, I know a lot of “precise” things about my visitors, then yeah, I do “know” that, because it’s a fact.

Or to slander by implying about things you don’t even know what they may be.

Slander? What?

My point is: You should design a site to be fast and lightweight for everybody, not just mobile users. And not remove content and features for some groups.

If it’s a pain to navigate the “real site” on a mobile, I would say that is poor design of the site, then. I think that the full site should be as easy to use on a mobile as it is on a desktop, call me crazy. Yes, even the ads.

If the “design details” can be stripped out and the site does what it should without them when viewed on a small screen, then maybe they don’t really need to be there in the first place?

Again, not saying don’t use them, just use them wisely.

Well… lemme see if I can explain it piece by piece.

The markup is pretty much your normal semantic markup for a website. Headings to start each subsections, horizonatal rules for semantic section breaks when a heading might not be appropriate (like before the footer) or for consistency of flow (between the menu and the content area). If you view the page with CSS off, you get a decent idea of what screen readers, search engines, and people on narrow bandwidth who disable … everything… tend to see. That’s why we have the concept of progressively enhancing a page; write the markup first with no real concern for what it’s going to look like on screen, print, or any other specific target.

The ‘magic’ of the markup are our presentational hooks. It should be noted that presentational hooks are NOT presentation – it’s why we have DIV and SPAN, to allow us to hook into the content without changing the meaning… that our content should already have.

It’s also why HTML 5’s “section”, “nav”, “header” etc are a pointless waste of markup, and amount to applying meaning around things that already have meaning.

div#pageWrapper as the outermost container is naturally used to control our widths across the entire page. It’s SO much easier to use one element for that than to waste time declaring widths on every last little blasted thing. This is where a LOT of people screw up on their page designs and CSS.

div#columnWrapper is there to contain our floats, and provide any extra style we might want. If you want to add something like faux-columns, this element would be where that would go.

div#contentWrapper, div#content – using a double wrapper lets us do a holy-grail type layout of having the most important thing – the main content, be our fuild center column and keep it first in the source order – without the headaches and hacks needed to implement it using just one DIV… oh noes, an extra DIV that’s actually serving a purpose. (You’ll see me railing against pointless DIV all the time – this isn’t one of them!)

The outer div#contentWrapper is floated at 100% width, so it takes up the entire screen. The inner DIV gets margins to make room for the columns to be rendered over, and normal padding.

div#firstSideBar and div#secondSideBar would be our two seperate columns for the three column layout – but to treat them as a single column we have to wrap both of them in a third div.

For the two column layout, our default which as discussed so far is the ‘lowest common denominator’ of desktop browsers that don’t know media queries, simply applies a right margin to Content… then uses the classic holy grail trick of a negative margin on #sideBarWrapper to reduce it’s width below 0px.

#contentWrapper is 100% width and floated left – so there’s no pixels left for a float to go next to it. Using the negative margin to make #sideBarWrapper 0 width or narrower, floats it up OVER it. Poof, two columns.

Our first media query for making the three column layout uses this:

<link
	type="text/css"
	rel="stylesheet"
	href="bigScreen.css"
	media="screen and (min-width:64em)"
/>

Which means any screen device wider than 64em gets that stylesheet layered on top of the non-query one.

Inside that stylesheet all I do to make the third column is put a margin on each side of Content to make a place for the sidebars to render, strip the style off the outer #sideBarWrapper and instead apply columns to the inner #firstSideBar and #secondSideBar.

I set them both to the same width, and float them both the same way. For the second sidebar I just swap what side the margin is on, making it overlap to the right instead of the left, and then slide it back over -100%… basically the normal holy-grail type three column layout. IF you want them reversed with the first one on the left, just change the standalone #secondSideBar to #firstSidebar. You could even do this:


#content {
	margin:0 38em 0 0;
}

#sideBarWrapper {
	float:none;
	width:auto;
	margin:0;
}

#firstSideBar,
#secondSideBar {
	position:relative;
	float:left;
	width:18em;
	margin-left:-19em;
}

#secondSideBar {
	left:-19em;
}

It also increases the max-width. You have to remember I designed for queryless FIRST… if we can go to three columns using queries, we can go wider.

For the small screen version, we just want to strip out the columns… so first, let’s target small screens:


<link
	type="text/css"
	rel="stylesheet"
	href="smallScreen.css"
	media="screen and (max-width:640px)"
/>

Anything 640px or narrower gets that stylesheet applied to it in additon to our queryless one. All I did here was decrease the min-width to that of the lowest end Opera mini devices. Anything smaller… really shouldn’t be used for web browsing or is going to ignore all this anyways. I set the width to 100% so it goes edge to edge – screen real-estate on small screens is precious, don’t waste it on a background…

Stripping off the columns is then easy. Get rid of all the margins, remove the floats on #sideBarWrapper. On a real layout you may have other styling you might also want to strip off it – I would advise stripping background off of body, so the mobile browser isn’t wasting time trying to render or load it. Excessive use of CSS3 properties can really hog memory and slow down rendering, so axing a number of those can also help.

Testing is important on that; getting a real iPod/Pad/Phone AND a droid device is a good start – though getting a Mac, building a Hackintosh, or tricking OSX into running under VirtualBox to use the iOS Simulator that comes with xCode lets you nab several Apple devices at once.

I have a legal Hackintosh to that end – cute loophole; you can only legally run OSX on Apple branded hardware. I gave my ‘parts pile’ Apple IIe Platinum (no psu, busted mainboard – as opposed to my good one that still runs fine) a ‘upgrade’ by stuffing a Atom 330 motherboard and the USB keyboard from a dead G3 iMac into it… Though I’m thinking on using this dead G5 Tower a friend gave me with a i7 920 board for a more capable one.)

Again why I consider this an example, NOT a framework to be perfectly copied. On top of the idiocy of frameworks in interpreted code on narrow pipes, they are often inflexible or require so much effort to learn well enough to modify with confidence, you’d be better off just working with scratch for each different type of page.

It’s all about the process of building up a page with progressive enhancement… Content should dictate layout, NOT the other way around. Make your non-css semantic page, use CSS to bend it to your will for non-media query screen and print, then use media queries to further refine screen by size. That way when/if some fancy bit of new technology is missing, it gracefully degrades.

… and again why drawing some goofy picture of a layout in Photoshop first tends to be little more than a disaster filled with ‘not viable for web deployment’ concepts.

Please keep the discussion civil, no personal attacks.

Danke.

Hey guys, have you seen this ems-based media-query layout. It allows you to flexibly keep optimal line length and layout ratios (the reason I would use fixed layout) as a function of the width of window measured in ems. There is a bug with webkit that doesn’t execute media-queries on window resize.

http://blog.cloudfour.com/the-ems-have-it-proportional-media-queries-ftw/

What’s your thoughts?