"Mr Branding" is a blog based on RSS for everything related to website branding and website design, it collects its posts from many sites in order to facilitate the updating to the latest technology.
To suggest any source, please contact me: Taha.baba@consultant.com
Wednesday, November 4, 2015
A Primer on Using Flexbox with Compass
There is no doubt that flexbox is an effective solution for laying out web pages. However, past struggles with browser support have resulted in many developers having little knowledge of the flex layout and the sheer power that it holds. By referencing caniuse.com however, you can see that flexbox is now supported by pretty much all major browsers, thus making knowledge of the layout imperative to those who wish to stay current in web development.
Therefore, I have created this guide to help you become more familiar with flexbox by integrating the Compass CSS framework. I'll use Compass to guide you through different flex-containers to show you how flexbox lays out child items, or flex-items, across different axes. Additionally, I will be to show you how easy it makes this process as it eliminates the need to include those pesky vendor prefixes that are still required for the deepest possible browser support.
Before we begin however, I’ll provide a brief overview of flexbox, so we fully understand the different mixins we will be using, and the effect they are having on our code.
[caption id="attachment_118385" align="aligncenter" width="659"] Flexbox explained via CSS-Tricks.[/caption]
As you can see, flexbox consists of 2 axes — a main axis, and a cross axis. By default, flexbox will display items in rows that run from left to right along the main axis. On the other hand, the flex layout can display items in columns that stack on top of one another. For the sake of this article, I will only be dealing with the flex-containers, and how they can be manipulated. Throughout the tutorial, feel free to reference Compass’ documentation on flexbox, which provides information on the mixins I’ll be covering.
[author_more]
The display-flex()
Mixin
First, let’s take a look at my initial example, which shows a basic flex-container with four flex-items. Flexbox is a new feature in CSS, so we need to import the compass/css3
library in order to utilize Compass’s flexbox mixins. Once I’ve imported the library, all I have to do is include the display-flex()
mixin to define a flex container. As a result, I’ll now have a flex-container with items that run from left to right, and shrink as the viewport decreases.
See the Pen Flexbox with Compass: display-flex() by SitePoint (@SitePoint) on CodePen.
[code language="sass"]
.flex-container {
@include display-flex();
// flex is the default value
}
[/code]
The flex-wrap()
Mixin
If you narrow the viewport in the demo above, the flex-container will run out of space and a scrollbar will appear at the bottom. I can use a number of techniques in order to combat this. In the next example, I’m going to use the flex-wrap
mixin to make the items in this flex-container wrap (i.e. drop to the next line) when the size of the viewport decreases.
See the Pen Flexbox with Compass: flex-wrap() by SitePoint (@SitePoint) on CodePen.
[code language="sass"]
.flex-container {
@include display-flex();
@include flex-wrap(wrap);
}
[/code]
As you can see, the .flex-container
rule set now includes Compass’s flex-wrap()
mixin, which causes flex-items to stack on top of one another as they run out of space inside the viewport. Additionally, this mixin can take the values of nowrap
and wrap-reverse
. nowrap
is the default value for flex-containers, and wrap-reverse
will reverse the order in which the items are stacked.
By checking out the example below, you can see wrap-reverse
in use:
See the Pen Flexbox with Compass: wrap-reverse by SitePoint (@SitePoint) on CodePen.
[code language="sass"]
.flex-container {
@include display-flex();
@include flex-wrap(wrap-reverse);
}
[/code]
The flex-direction()
Mixin
By default, flexbox will automatically render flex-containers as rows. Therefore, I did not have to define the flex-direction
property in the first two. If instead we wanted to display flex-items stacked on top of one another, I simply need to pass in a value of column
into Compass’s flex-direction()
mixin.
See the Pen Flexbox with Compass: flex-direction() by SitePoint (@SitePoint) on CodePen.
[code language="sass"]
.flex-container {
@include display-flex();
}
.flex-container:nth-of-type(2n) {
@include display-flex();
@include flex-direction(column);
}
[/code]
The flex-flow()
Mixin
The next example I’m going to discuss will demonstrate how to create flex-containers using the shorthand method. Moreover, I can combine the flex-direction
and flex-wrap
properties, and pass these values into the flex-flow
mixin. Below, you can see this mixin being used to create a flexible row, which will run from right to left. As a result, the items will stack from the top down because a value of wrap-reverse
is passed into the mixin.
Continue reading %A Primer on Using Flexbox with Compass%
by Thomas Greco via SitePoint
Rain & Water Effect Experiments
Some experimental rain and water drop effects made with WebGL and shown in different demo scenarios.
by via jQuery-Plugins.net RSS Feed
Paul O’Rely
by Rob Hope via One Page Love
Bureau Tonic
by via Awwwards - Sites of the day
How to Create Facebook Ads With Emails: 5 Creative Ideas
Do you have an email list? Are you looking for creative ways to use Facebook ads? With Facebook custom audiences, you can reach your email subscribers with relevant Facebook ads. In this article I’ll share five ways to target your email subscribers with Facebook ads. #1: Serve Ads to All Email Subscribers Since it requires […]
This post How to Create Facebook Ads With Emails: 5 Creative Ideas first appeared on Social Media Examiner.
Social Media Examiner - Your Guide to the Social Media Jungle
by JD Prater via Social Media Examiner