Wednesday, July 5, 2017

Building Mega Menus with Flexbox

Mega Menus with Flexbox

As you are probably aware, Flexbox has recently gained momentum with increasing browser support. It allows developers to build complex user interfaces without dealing with unwanted CSS and JavaScript hacks.

Flexbox uses a linear layout model, which allows us to lay our content horizontally or vertically without involving calculations for spacing. The flex layout reacts responsively to the elements within the container, thus requiring fewer media queries.

In this article I will make use of this layout model to build a mega navigation menu and in the process you’ll see how simple it is to build and extend user interface components with flexbox.

I won’t discuss individual Flexbox properties in detail here, but instead the focus will be on the practical use of the features. For a basic introduction to Flexbox, please refer the following resources:

What Are We Building?

To get an idea of what I'll be showing you how to build, take a look at the full-screen CodePen.

This tutorial is divided into three parts:

  1. Building the navigation bar: Using flexbox to build a simple navigation bar for our imaginary e-commerce platform
  2. Building a single drop-down section
  3. Limiting a single drop-down section to three columns

Building the Navigation Bar

The markup for the navigation bar is simple. I will handle everything with two classes (navbar and menu) for the sake of this demo. The CSS here will exclude any styles unrelated to the tutorial.

[code language="html"]
<nav class="navbar">
<ul class="menu">
<li>
<a href="#">
Electronics
<!-- FontAwesome icon -->
<i class="fa fa-angle-down"></i>
</a>
</li>

<!-- ... More nav items here... -->

<ul>
</nav>
[/code]

The navbar class is responsible for centering our navigation bar in the available space, but I’m going to focus on the menu class where I will use flexbox.

I want my navigation items to be laid out horizontally. Also, I want each item to be spaced equally and shrink as needed if there is not enough space.

First, I need to establish a flex formatting context on the .menu element, which I’ll do with display: flex. Now, all the direct children of the .menu element (which is the flex container) will be flex items.

Next, I want the menu items to be equal in width. I’ve added flex: 1 to make them grow uniformly with equal width. Here is the code:

[code language="css"]
.navbar .menu {
display: flex;
position: relative;
}

.navbar .menu li {
flex: 1;
display: flex;
text-align: center;
}

.navbar .menu a {
flex: 1;
justify-content: center;
color: #ffffff;
padding: 20px;
}
[/code]

Looking at the code, you might be wondering why I repeated display: flex for all the flex items (.navbar .menu li).

In the demo, when you hover over a menu item, its background color changes. If I don’t set the display property of the flex items to flex, then only the li elements will have equal width and not the content inside them (i.e. some highlighted part will be clickable and others will not).

Continue reading %Building Mega Menus with Flexbox%


by Kalpesh Singh via SitePoint

Lisa App

Lisa App

Launching soon page for an app called Lisa that uses an algorithm to chose the most engaging photo (for Instagram) out the options you give her 🤔 The One Pager was build with the powerful Slides 3 Framework by Designmodo.

by Rob Hope via One Page Love

#297: This Week's HTML5, CSS, Browser, and Frontend News

Frontend Focus
Issue 297 — July 5, 2017
..due to it already being a grid system.
Rachel Andrew

A round up of a popular Twitter thread asking disabled people what they find difficult about using the Web. Poor color choices and a lack of video captions were common problems.
Hampus Sethfors

How the Constraint Validation API works, why it’s not all that great, and approaches for validating forms properly.
Peter-Paul Koch

Join thousands of software development teams who discover and reproduce performance issues and JavaScript errors affecting their users with greater speed and accuracy. Try Raygun free for 14 days.
RAYGUN   Sponsor

Eric Bidelman runs through how to use Headless Chrome, using Karma as a runner and Mocha+Chai for authoring tests.
Google Developers

An interesting series of posts that digs into the practicalities of using WebGL to do GPU-based calculations.
Vizit Solutions

Ire covers the difficulty of writing progressively enhancive CSS, and offers some tips on how to overcome it.
Ire Aderinokun

“How many times you wanted to change code (especially CSS) and you were afraid to death that you’d break everything.”
Ahmed Mahmoud

A browser-based networking library that exposes a simple peer-to-peer API that allows for peer discovery and the ability to send data (via WebRTC) to others.
Mozilla Hacks

Some details on how Safari 11 and iOS 11 implement WebRTC, and tips on bringing support to your own site.
WebKit

Jobs

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

In Brief

Using CSS Variables Correctly tutorial
Mike Riethmuller

Experimenting with the Background Fetch API tutorial
Phil Nash

How to Rename a Font in CSS tutorial
Zach Leatherman

Repeatable, Staggered Animation Three Ways: Sass, GSAP and Web Animations API tutorial
Opher Vishnia

Creating Organic Shape Animations with SVG clipPath tutorial
Mary Lou

Download the free GrapeCity Wijmo E-book 
This free e-book teaches you about the strengths and weaknesses of JavaScript’s top frameworks.
GrapeCity Wijmo  Sponsor

Five Huge CSS Milestones of the Past 10 Years opinion
Chris Coyier

Why Use a Third-Party Form Validation Library? opinion
Chris Coyier

Looking At The Future of Responsive Design opinion
A look at the evolution of responsive design and some thoughts on where it’s going.
Rupert Sharp

Did CSS Get More Complicated Since The Late 90s? story
An interesting look into the early days of CSS and changes that have occurred since.
Hidde de Vries

Taking Responsive Web Design Beyond the Visual podcast
A discussion on a wider interpretation of responsive web design that includes user context, push notifications, future devices and accessibility.
SitePoint

Yes, Your Site Too Can (and Should) Be Accessible video
How The Financial Times went from being “generally oblivious about accessibility” to making it a core part of their process.
Laura Carvajal

$20 Credit on a New Account 
Linux cloud hosting starting at 1GB of RAM for $5/mo. Use promo code HTML520 and get $20 credit.
linode  Sponsor

URLColors: Colored Borders for Sites Based on URL Patterns tools
To distinguish dev, prod and staging versions of the same site, perhaps.
Chrome Web Store

Infinite Scroll v3: As Users Scroll, Automatically Load More tools
Note it’s both GPL3 and commercial.
Metafizzy


by via Frontend Focus

Creating a Blogging App Using React, Part 3: Add & Display Post

#165: How Desktop-Era Frameworks Can Thrive on Mobile

Mobile Web Weekly July 5, 2017   #165
Peter Cooper recommends
Building m.uber: Engineering a High-Performance Web App for the Global Market — How Uber Engineering designed m.uber, a lightweight web app that delivers a native app experience for riders on mobile.
Angus Croll
Peter Cooper recommends
Making the Jump: How Desktop-Era Frameworks Can Thrive on Mobile — How do tools that grew up on the desktop, like Ember, Angular and React, make the jump to the mobile future?
Tom Dale
Brian Rinaldi recommends
NativeScript 3.1 Released — Introduces new features like the Chrome DevTools Elements tab, Android snapshot builds, and more.
NativeScript
Brian Rinaldi recommends
Taking Responsive Web Design Beyond the Visual — A discussion on a wider interpretation of responsive web design that includes user context, push notifications, future devices and accessibility.
SitePoint
Chris Brandrick recommends
How to Enhance Mobile Interactions with Sound Design — Some insights, plus an introduction to the Facebook Sound Kit, a collection of interaction sounds they’re making available.
Will Littlejohn
Brian Rinaldi recommends
Code a Real-Time NativeScript App: Geolocation and Google Maps — Learn how to work with geolocation and Google Maps in NativeScript apps.
Wernher-Bel Ancheta
Brian Rinaldi recommends
Code a Real-Time NativeScript App: SQLite — How to integrate a SQLite database into a NativeScript app to store data locally.
Wernher-Bel Ancheta
Peter Cooper recommends
An Interview with the BBC's Sareh Heidari — A quick 13 minute podcast with a BBC News web developer discussing accessibility, globalization, and CSS at scale.
Responsive Web Design Podcast
Chris Brandrick recommends
Looking At The Future of Responsive Design — A look at the evolution of responsive design and some thoughts on where it’s going.
Rupert Sharp
Brian Rinaldi recommends
React-UWP: React Components That Implement Microsoft's UWP Design and Fluent Design System
myxvisual
Chris Brandrick recommends
Kitten Tricks: A React Native Mobile Starter Kit — Features over 40 free and open-source app screens.
Akveo


by via Mobile Web Weekly

How to Optimize Your Facebook Dark Posts

Want to publish the best possible Facebook posts to your page? Looking for a way to evaluate which versions of your posts perform best? Facebook dark posts allow you to run and test content without posting that content to your page’s timeline. In this article, you’ll discover how to use dark post ads to optimize [...]

This post How to Optimize Your Facebook Dark Posts first appeared on .
- Your Guide to the Social Media Jungle


by Eleanor Pierce via

Complexify – jQuery Plugin to Create Strong Passwords

jQuery Complexify helps you to accurately gauge the quality of a user's password to give them visual feedback, and to enforce a minimum level of security.


by via jQuery-Plugins.net RSS Feed