Angular Instead of Media-Queries
Join the DZone community and get the full member experience.Join For Free
if you’re a developer or a ux person, unless you’ve lived under a rock for the last few years, you understand responsive web design and it’s implications for site construction.
it’s clever stuff of course, and there are many examples of sites that adapt between desktop and mobile without a redirect. there’s also a backlash . i’m intrigued by that. i feel there is an element of “tail wagging the dog” about css driving more sweeping experience changes. i’m not sure css is the place for something that feels like conditional logic.
- whether the viewport size was best as a single ‘content’ column, or multi column: navigation affordances in the left and right ones, and ‘content’ in the center
- the width of left and right columns being 15 pixels or more that that, and implicitly how wide that central ‘content’ column is.
by the way, the source on github is – https://github.com/paul-hammant/angular_instead_of_media_queries . the actual deployed site is http://paul-hammant.github.com/angular_instead_of_media_queries (be sure to try this on mobile devices as well as desktop … and try resizing the window).
there’s content that disappears from the left and right columns (as they get smaller). there’s also a point at which those columns function as margins (min width 15px). it all works quite well. the three columns are implemented in regular html tables. yes that technology, that was superseded by <div> elements (and css ) some ten years ago.
the page as we have it today looks fairly bad though. we detached the css that the github pages site generator gave us in the initial commit. we will add that back incrementally, as it’s likely that we don’t need all of it any more. we definitely want the fancy fonts and colors back. where we started and where want to circle back re themes:
where are now (1993 called and wants it’s style back):
what that looks like if we reduce the size:
yet to test / drilling into the code
how does google index this site? what does it look like in preview?
the angular attributes will be ignored by the search-bot. take a look at the main source file and look for things prefixed with ng-. specifically hg-hide, ng-show and ng-style. here, let me do an ‘ack’ for you:
ph7785:angular_instead_of_media_queries paul$ ack " ng-" index.html 2:<html ng-app> 28: <body ng-controller="responsivedemoctrl"> 31: <td ng-style="leftmarginstyle"></td> 38: <td ng-style="rightmarginstyle"> 39: <a ng-hide="onecolumn" href="https://github.com/paul-hammant/angular_instead_of_media_queries" class="button"><small>view project on</small>github</a> 43: <td ng-style="leftmarginstyle" style="width: 40%"></td> 44: <td ng-style="middlestyle" style="width: 20%"> 91: <td ng-hide="onecolumn" ng-style="rightmarginstyle" style="width: 40%">
ok, so that’s not 100% clear, so take a look in the source, and scroll around .
i’ve also put the word ‘cachinnation’ in the page, so that i can search later for it in google-search. well, search for “paul hammant cachinnation” perhaps. cachinnation means ‘to laugh hard, loudly, or convulsively (guffaw)’.
here’s what that preview screenshot looks like:
looks ok, right? i’m not sure what’s happened to the left-hand column. maybe the preview maker trims whitespace at the margins. by the way, it took the google search-bot about seven hours to find it and make the preview picture.
there is some suggestion online that the word ‘responsive’ should mean media-queries solutions exclusively, so i’ve been careful to minimize use of that.
Published at DZone with permission of Paul Hammant, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.