Monday, October 10, 2016

Bootstrap Vertical Carousel

Bootstrap has only a traditional horizontal carousel. This plugin has the HTML and CSS to get it to animate vertically with up/down carousel controls.


by via jQuery-Plugins.net RSS Feed

‘Reskinnable’ SVG Symbols: How to Make Them (..and Why)

The widespread adoption of SVG in modern web pages has really ramped in 2016 thanks to its, file size, scalability and CSS .

It can be used for icon systems (take a look at Build Your Own SVG Icons), although icon fonts, in some cases, can be preferable (some info here: The Great Icon Debate: Fonts Vs SVG).

But SVG can also be used for logos or graphic elements (at least not overly complex ones) and its natural flexibility makes it a perfect solution for responsive sites (take a look at Sara Soueidan’s Making SVGs Responsive with CSS).

The use of SVG makes it possible to target and change the size and color of an entire element through CSS, but, unless your SVG code is embedded in your HTML page, you can’t modify a single portion of it in this way.

The problem

Let’s look at a simpler example. Here we have an image that we need to display in a range of colors.

Same SVG shape. Different colors.

Of course, traditionally we would simply create three standalone images – each with a different flavour. But what if we wanted to use a single SVG file and style it at render time?

Furthermore, is there a way we make our image a ‘SVG symbol’ to take advantage of browser caching?

I’m going to refer to this a “Reskinnable SVG symbol” – the “bones” of your SVG image remain the same but it’s easy to change the surface appearance.

The perfect solution would be accessing symbol elements through a CSS selector and add some rules to them (the same method that we would have used with embedded SVG).

In the following sample, I’ve added a class (top, right, bottom and left) to each triangle, arranged the image as a symbol and tried to modify it thru CSS, in this way:

[code language="css"]
.top { fill: #356BA5; }
.right { fill: #357FD9; }
/* and so on... */
[/code]

Unfortunately, at the moment this only works with Firefox, as the following Codepen demonstrates. The second image appears in tones of blue only on Firefox (I’ve embedded the symbol code in the pen for convenience, but we have the same results with external SVG files).

See the Pen svg element editing (demo 1) by Massimo Cassandro (@massimo-cassandro) on CodePen.

In large projects, where we may have many elements like that, maintenance issues are an important factor, so I’m always searching for a way to better organize project assets.

My goal was a pure CSS solution: the previous sample can be rewritten using a single-triangle-SVG to be rotated, moved and colored using CSS.

But I didn’t like this solution: it seems to me that it simply moves the problem, without solving it. How many real-world logos have components that all have the same shape?

Sara Soueidan explains the problem much better then I do and offers us a clever solution using CSS variables. Unfortunately CSS variables are still an experimental technology and Microsoft browsers don’t support them.

The Solution

As it often happens, the solution is so head-slappingly simple that it will make you feel stupid for not having thought about it before.

I came across it looking at the new Medium logo some months ago (it seems Medium has since changed their logo code – you’ll have to take my word).

qJVnVmr

You can see that Medium logo consists of four ‘shapes’, each filled with a different flat color. The B&W version is identical to the green one (except for the colour, of course).

The solution for having a single file for both versions was to simply build a symbol for each shape, each of them within the same viewBox.

Let’s apply it to our example and create a symbol for each shape in our image. They all share the same viewBox of the whole image (0 0 54 54), so they place themselves in the right position without any additional instruction. Just take care to avoid fill, stroke, style etc. attributes in the symbol code).

Continue reading %‘Reskinnable’ SVG Symbols: How to Make Them (..and Why)%


by Massimo Cassandro via SitePoint

Quiz: Do You Know How to Secure WordPress?

Diving into How Hashes Work in Ruby

Ruby's Hash is arguably the most useful data type in the language. Utilizing a structure that lends itself well to modelling real-world problems, combined with speedy lookups, it is frequently the backbone of scripts, web pages, and complex business logic. It was even once used internally by Ruby to store all your functions, variables, and constants (although modern Ruby approaches this differently by using branch prediction of hot paths and call-site method caching; that's another post!) We often take it for granted that it "just works". Today we're going to delve into the internals of Hash, seeing exactly why it works, how it is so efficient, and how it is implemented. Onward!

Continue reading %Diving into How Hashes Work in Ruby%


by David Bush via SitePoint

Getting Started With Ionic: Cordova

AtoZ CSS Quick Tip: How to Use the nth-Child CSS Selector

N is for nth-child

We have many powerful CSS selectors available for finding elements on the page and applying styling to them.

The nth-child pseudo selector is probably the most powerful due to the flexibility of its (an+b) expression for finding patterns of elements. This was discussed in detail in the video screencast all about nth-child.

In this quick tip, we’ll look at when you can use nth-child and when you should use a standard class.

When should I use nth-child?

This is a question I get asked by students quite frequently. The first thing to note is that (unfortunately) it depends on the situation. But I’ll try and provide some good baseline criteria.

Firstly, all the :nth-child like selectors are only supported in IE9 and above (with the exception of :first-child) so the first thing to check is the age of browser your project needs to support.

If you need to support IE8 (firstly, sorry to hear that!) then there’s really only one thing you can do; use classes or use :first-child.

Tip 1: Use :first-child when supporting IE8

Imagine you have a horizontal unordered list of nav links and your design needs to have a border to the right of each item - but not the last item.

Instead of adding the border on the right and needing to remove it from the last one, add the border on the left and remove it from the first one.

[code language="css"]
.site-nav li {
border-left: 2px solid grey;
}
.site-nav li:first-child {
border:0;
}
[/code]

Continue reading %AtoZ CSS Quick Tip: How to Use the nth-Child CSS Selector%


by Guy Routledge via SitePoint

Storm

opl-small

Minimal spacious One Pager with a narrow column layout for 'Storm' - a London-based digital agency focused on eSports.

by Rob Hope via One Page Love