Wednesday, January 18, 2017

Writing Element Queries Today Using EQCSS

A man looking at his phone and computer screen with different inkblots on them.

This article was peer reviewed by Adrian Sandu, Giulio Mainardi and Tom Hodgins. Thanks to all of SitePoint's peer reviewers for making SitePoint content the best it can be!

We are all familiar with using media queries in CSS to change the appearance of an element based on screen width. Element queries are similar to media queries, however, now the responsive conditions apply to individual elements on a web page instead of the viewport. For example, you can now apply different style rules to an element based on its own width, the number of characters that it contains or how much the user has scrolled.

Why Do We Need Element Queries?

As I mentioned in the introduction, element queries can help you style elements based on a number of properties instead of just the width and height of the viewport. Other than that, there are a few other situations where the library can prove to be of great use.

Let's say you have just created a beautiful responsive layout where all the elements fit together perfectly. Now, you are asked to add another column to the web page alongside existing ones. This will reduce the space available for all columns.

Your images and text which had perfect proportions for an 800px wide column on 1366px wide viewport may not look so good inside a 600px wide column on the same viewport. In such cases, the viewport width has not changed at all but individual columns are narrower because they had to make space for the sidebar. Using element queries instead of media queries in situations like this one can save you a lot of time because you won't have to rewrite the CSS every time there is a change in the layout.

In the following demo, if we have a smaller viewport (narrower than 500px), we set the image width to 100% and move it all into a single column. However, on a larger viewport, if you click on the "Add Sidebar" button, the width of our main column reduces significantly without any change in viewport width. Therefore, the image looks too small because the viewport width has not changed.

See the Pen Adding More Columns to a Layout by SitePoint (@SitePoint) on CodePen.

Now, let's assume you are creating a widget or plugin and you are using media queries to make it responsive. The problem here is that the widget can be inside a container whose width is equal to the viewport or a container whose width is just one-fourth of the viewport. If the width of the widget depends on the width of its container, relying on the size of the viewport to style it properly won't work. Element queries can now come to the rescue! Element queries can work well here because they use the widget's own width to style it.

In the image below, the same widget has been placed twice on a web page. You can see that the viewport width is the same but the width of these two widgets is different. Since the style rules are being applied based on the width of widget, both of them fit perfectly in the layout.

Two items displaying differently in the same viewport

Continue reading %Writing Element Queries Today Using EQCSS%


by Baljeet Rathi via SitePoint

This Week in Mobile Web Development (#141)

Read this on the Web

Mobile Web Weekly January 18, 2017   #141
Brian Rinaldi recommends
Why Native Apps Aren't Really Doomed, for Now — A response to Eric Elliott’s article, Matt argues that, while web apps may win in the long run, we are a long way away from that.
Matt Asay
Holly Schinsky recommends
Battery Status API - Hardware Access API — How to use Battery Status API to directly access the hardware your HTML page is running on.
The Web Juice
Peter Cooper recommends
The Problem With AMP (Accelerated Mobile Pages) — AMP promotes lock-in and provides a poor user experience, explains Kyle.
Kyle Schreiber
Sponsored
Level up from Hybrid — Upgrade to JavaScript Native and native controls. Build truly native mobile apps w/ Angular or JavaScript. Free & Open Source.
NativeScript

Holly Schinsky recommends
Mobile Development Framework Reviews — A comparison of popular mobile app frameworks and features.
G2 Crowd
Peter Cooper recommends
How I Built a Fast Uber Clone for the Mobile Web — A developer shares some performance tips picked up while building an Uber-esque mobile webapp with React.
Narendra N Shetty
Chris Brandrick recommends
AMP is Google’s Last Hope for Relevance in Mobile Search — Google is quietly creating a privatized, walled kingdom within the open web that their company was built on.
Alex Austin
Holly Schinsky recommends
Writing a Cordova Plugin in Swift 3 for iOS — How to write a Cordova Plugin using Swift 3 and supported by the latest Xcode 8.2.
Simon Prickett
Holly Schinsky recommends
Build a Twitter app with VueJS, Framework7, PhoneGap, Webpack — Learn how to create a real-world Twitter app for iOS and Android from scratch using Framework7 and VueJS.
Timo Ernst
Holly Schinsky recommends
Getting Started with React Native Development for Windows — A getting started guide to building React Native Windows apps.
Kevin VanGelder
Holly Schinsky recommends
Introduction to Progressive Web Apps (Offline First) — An introduction to Progressive Web Apps.
Prosper Otemuyiwa
Holly Schinsky recommends
Progressive-Web-App: A Starter for Progressive Web Apps — A starter template for building a progressive web app with React.
Glenn Wedin
Holly Schinsky recommends
webpack-mobile-f7 — A VueJS webpack template to setup a Framework7 project with Cordova.
AppointmentGuru
Brian Rinaldi recommends
Web App Manifest Generator — A web-based tool designed to make it easier to create the web app manifest for your site.
Github
Brian Rinaldi recommends
Quasar Framework — A new framework that aims to allow you to build responsive sites, hybrid mobile apps and Electron apps with one codebase using VueJs 2.
Holly Schinsky recommends
Building Ionic 2 Applications for iOS without a Mac — A guide to building iOS mobile apps on a Windows machine.
Josh Morony
Brian Rinaldi recommends
A Guide to App Store Images — Rob Lauer lists all the requirements for the various app store images that an app can have including icons, screenshots, splash screens and more.
Telerik Developer Network
Holly Schinsky recommends
Gestures Glamour: Setting Up a Touch Menu — Setting up touch-drive gestures in your mobile apps with JavaScript.
Rita Dias
Brian Rinaldi recommends
Google AMP Cache, AMP Lite, and The Need for Speed — A look at two recent improvements: optimized image delivery and a project called “AMP Lite.”
Google Developers Blog
Brian Rinaldi recommends
Exploring App Module And App Component In An Ionic 2 App — A look at the functionality of both the App Component and the App Module in Ionic 2.
Ashteya Biharisingh
Holly Schinsky recommends
5 Web Trends for 2017 — What’s coming with PWAs, Angular, React, and Vue; the rising tide of functional reactive; looking beyond REST to GraphQL and Falcor; and the future of artificial intelligence on the web.
Allyson MacDonald
Brian Rinaldi recommends
The Power Of Collaboration — Sani shares a story of collaborating on a Netflix app using Ionic.
Sani Yusuf
Curated by Brian Rinaldi and Holly Schinsky for Cooperpress.
Cooperpress is located at Office 30, Fairfield Enterprise Centre, Louth, LN11 0LS, UK
Update your email address
or stop receiving MWW here


by via Mobile Web Weekly

New Coffee Break Course: Reactive Programming With RxJS

Are You Improving Your UX with Analytics?

If you were to rate your UX savviness, what would it be out of 5?
If I were to be completely honest with myself, I’d like to think that I know some UX, perhaps not a 5 but a comfortable 3?

So what happens when you’re discussing or testing usability with a client or boss? How does that conversation end, if you both have different ideas on best practice? You know some UX but your client/boss, on the other hand, knows the customer inside-out. Who wins? Unfortunately, this time it probably won’t be you (or me).

Why? Well because when making design decisions, it’s not just about aesthetics. If your design is not made perfectly (which it probably won’t be), you’ll find that your user flow needs some additional work. You’ll need to find a solution to your design that may not be that obvious to the naked eye without data.

Learn about how you can use website and app analytics to make informed design decisions whilst your users' have a positive experience. It will inspire you, it will guide you, and you will improve your understanding within the digital playing field (as well as your career objectives).

Continue reading %Are You Improving Your UX with Analytics?%


by Angela Molina via SitePoint

Crash Reporting an Android App with Crashlytics and Fabric

The Fabric Library from Twitter provides a suite of tools to complement and enhance your apps. In this tutorial I will focus on the crash reporting features that help pinpoint and track app crashes.

Continue reading %Crash Reporting an Android App with Crashlytics and Fabric%


by Theodhor Pandeli via SitePoint

This Week's HTML5, CSS and Browser Tech News #273

Read this e-mail on the Web
FrontEnd Focus
Issue 273 — January 18, 2017
Ire Aderinokun is excited about adopting Feature Queries, Grid Layout and Native Variables this year.
Ire Aderinokun

A look at the area above the browser’s viewport where users expect to be reassured about a page’s legitimacy but where they can also be easily fooled.
Eric Law

A succinct 17 minute talk on the history of modern Web technology, Service Workers, apps, and where things are headed bringing it all together.
Nolan Lawson

Sencha, Inc
React can be used to build user interfaces (UIs) for web apps, but React developers have to provide the components to build the UI. Fortunately, there's a better way. Learn how React developers can now use Sencha’s powerful Ext JS components in their React apps, using the new Ext JS Reactor.
Sencha, Inc   Sponsor

AMP promotes lock-in and provides a poor user experience, explains Kyle.
Kyle Schreiber

A very thorough attempt to cover all the fundamental concepts you need to get comfortable with the CSS Flexbox model.
Ohans Emmanuel

Styled-components are used to enforce best practices by removing the mapping between styles and components, and include actual CSS in your JavaScript code.
Max Stoiber

Slanted, curved, or otherwise irregularly-shaped header sections are a modern Web design trend. Here’s a thorough look at some approaches to implementing them.
Ahmad Nassri

Designed for building Retina-ready ‘silky smooth’ animations and effects. Tons of demos, plus the GitHub repo.
Oleg Solomka

Jobs Supported by Hired.com

Can't find the right job? Want companies to apply to you? Try Hired.com.

In Brief

webpack 2.2 Released: The Popular Module Bundler news
Sean T. Larkin

Opera Launches Neon, A New Experimental Desktop Browser news
Frederic Lardinois

Edge Introduces Support for Content Security Policy Level 2 news
Microsoft

Web Rebels (June 1-2 in Oslo, Norway) Call For Papers news
Speakers to this much celebrated event are usually invite only so this is a great opportunity.

Live Workshop tomorrow: React Native, SVG and D3 news
Register for tomorrow’s live interactive online workshop with a two-week free trial to Forward Courses
Forward Courses  Sponsor

Full-Color Emoji Coming by Default to Microsoft Edge news
Twitter

Ultrasound Created by Web Audio API Could Be Used To Deanonymize Tor Users news
Slashdot

Random Numbers in CSS (using JS and CSS Variables) tutorial
Robin Rendle

A Simple Intro to localStorage and sessionStorage tutorial
For saving key/value pairs locally from the browser.
Alligator.io

Understanding the Critical Rendering Path tutorial
Knowledge of the Critical Rendering Path is incredibly useful for understanding how a site’s performance can be improved.
Ire Aderinokun

Building a responsive HTML5 app? Learn the must-know techniques with this whitepaper 
If you're a HTML5/JS dev, responsive web design is or will be a requirement in the near future. This whitepaper will give you the must-know on responsive web.
Progress  Sponsor

Pointing JS Links to Fragment Identifier Zero video
Harry Roberts

Modernizing Our Progressive Enhancement Delivery story
A look at how Filament Group is utilizing http/2 for speed and service workers for offline connections.
Scott Jehl

How I Destroyed My Blog's Performance with CSS Background-Blend-Modes story
“just because a browser has a feature, doesn’t mean you should use it”

Beware These 9 Design Elements Your Front-End Developers Hate opinion
Careful when sharing this with your bosses or customers ;-)
Marissa Epstein

'I Swore Never to Use CSS in JS, Here Are 6 Reasons Why I Was Wrong' opinion
Tal Bereznitskey

Moving Beyond localStorage opinion
.. to WebCrypto and IndexedDB?
Mo Bitar

tlapse: Create A Timelapse of Your Web Development tools
A utility that takes periodic screenshots of your site while you develop.
Typicode

CSS Triggers: A Table of Which CSS Properties Trigger Repaints tools
Paul Lewis and Das Surma

Clippy: A CSS 'clip-path' Maker Tool tools
The clip-path property lets you to make complex shapes in CSS by clipping an element.
Bennett Feely

The Top 50 Developer Tools of 2016 tools
Front-end technologies dominate these lists from StackShare.
StackShare

iTyped: Simple JavaScript Animated Typing Effect with No Dependencies code
Luis Vinicius

Curated by Peter Cooper and published by Cooperpress. If you like this, you may also enjoy: JavaScript Weekly, Node Weekly, and React Status.

Stop getting FrontEnd Focus : Change email address : Read this issue on the Web

© Cooper Press Ltd. Office 30, Lincoln Way, Louth, LN11 0LS, UK


by via FrontEnd Focus

Text Scramble Effect with Javascript

A snippet about creating tiny text decoding / scramble effect by using javascript.


by via jQuery-Plugins.net RSS Feed