Newer posts are loading.
You are at the newest post.
Click here to check if anything new just came in.

February 25 2014

07:30

February 17 2014

11:00

February 12 2014

13:50

26 Web Design Tutorials for Learning New CSS3 Properties

Advertise here with BSA


Over the past few years a number of prominent CSS3 tutorials have been published online. These are perfect for beginners who don’t have a lot of experience coding webpages. But developers who do have that experience may also find the more detailed articles quite insightful.

Take a look over this collection of posts related to newer CSS3 properties. There may be some you’re already familiar with, and others that you’ve never even heard about before. CSS3 provides developers with many different solutions used to solve individual problems. Also if you know any other great posts I’ve forgotten you can share with us in the post discussion area.

CSS3 Box Shadow Effects

various css3 box shadow effects tutorial

CSS Text Stroke

css css3 text stroke effect

Cubic-Bezier In CSS3 Transition

css3 transition cubic bezier tutorial

CSS3 :not Selector

css3 negation not selector guide

CSS3 Multiple Columns Layout

css3 multiple columns layout tutorial howto

CSS3 :First-Of-Type Structural Selector

css3 first type structural selector tutorial

CSS3 Linear Gradients

css3 linear gradients tutorial howto article

Transparencies and Gradients With CSS

css3 transparency gradient howto tutorial design

Using any font with CSS3

howto tutorial web fonts css3 article

CSS3 multiple background images

tutoral learn css3 multiple backgrounds howto

CSS background-size property

css background size property tutorial

The Skinny on CSS Attribute Selectors

basic guide tutorial using css attribute selector css3

CSS3 Reflection

tutorial howto code css3 reflection effect

Box Model Control with box-sizing

box sizing css3 tutorial howto model

Annotation Overlay Effect with CSS3

css annotation overlay effect css3 design

Understanding the CSS Clip Property

css clip property tutorial howto

Intro to CSS Pseudo-Classes

howto tutorial css3 pseudo classes article

List of CSS3 Pseudo-classes

list of css3 pseudo classes design website

2D and 3D Transform Techniques

css3 tutorial 2d 3d transition animation

CSS3 Transitions from Scratch

html css3 transitions and form effects

Smooth Fonts with CSS3

css3 alias font design typography howto

Background-clip with CSS3

css3 background clip tutorial howto article

Change Default Text Selection Color

howto update text select color design tutorial

Awesome Flat Buttons with CSS

css3 flat gradient button design howto coding

CSS3 Animations Using Keyframes

css3 keyframe animation design howto tutorial

Experimenting With CSS3 Keyframe Animations

experiment new css3 keyframes howto animate elements


Advertise here with BSA

February 11 2014

11:00

HTML, CSS, PSD and More: 24 Free Design Resources from January 2014


  

Creativity is like a cat. Sometimes it gives you head butts and rubs against you. Then it delivers you nothing but dead prey or stays away completely for days. As a creative professional you need to find ways to get creativity back, while your cat just needs you to patiently wait as long as it takes. Sparking your creativity is best done by inspiration and inspiration comes from many things, not the least other people’s work. In the face of this fact we’ve put together yet another set stuffed with HTML, CSS and PSD templates and added the best UI kits. Your cat will not be interested, but you should keep the following list safe and warm….

January 23 2014

11:00

Styling SVG with CSS: Capabilities and Limitations


  

SVG is the new standard for vector images in the browser. Vector editors such as Adobe Illustrator allow to directly save to that format and modern browsers have no problems to properly display SVG. As SVG graphics consist of markup, they can be created and maintained using your favorite text editor, just as you do with your HTML. It is even possible to style SVG with CSS, though you’ll need to know about quite a few differences in doing so, compared to styling HTML.

January 20 2014

11:00

HTML, CSS, PSD and More: 22 Free Design Resources from December 2013


  

Design resources are great in many ways. Some of us might just use them as they are, building their next project upon them. Others simply take them as an inspiration to create their own. All of us collect these resources. There’s no denying, we are hunter-gatherers. In the face of this fact we’ve put together yet another set stuffed with HTML, CSS and PSD templates and added the best UI kits. Bring it to the fireplace and hear everyone whoop with joy.

December 26 2013

18:47

The Benefits & Drawbacks to CSS Resets

Advertise here with BSA


CSS is a well-known language used for styling a website layout and various elements on the page. The specifications have evolved throughout CSS2 and into CSS3, creating a much simpler development process. Resets are used to clear out default browser settings so that each project will be rendered with the same baseline interface.

css code resets paper featured photo

However these resets will sometimes create problems you never thought about. Removing default properties like padding and borders may lead to adverse effects on input fields and other similar page items. In this article I want to share my own perceptions about the benefits and drawbacks of creating web projects with CSS resets.

Why Reset?

The primary goal of resetting elements is to remove discrepancies between different web browsers. Font sizes and line heights are two great examples which tend to differ between browsers and Operating Systems. You will save time debugging and it grants you more control to manipulate the standard HTML elements.

With absolutely no margins or padding you will have elements stacked right up against each other. This means you’ll also be required to define your own values, but I see this as a higher form of control over the layout(rather than a nuisance).

Simply stated, I get more value out of resetting the document than not. So this is my particular reasoning for sticking with it. Plus I get to learn first-hand about browser bugs and how to fix them accurately. Resets can be a blessing or a curse, and sometimes both. But in my opinion they are worth the effort when you’re consistently building new web projects from scratch.

Why Ignore Resets?

I’d say the first reason to ignore CSS resets would be larger file sizes. Granted the modern web can handle large bandwidth limits so this really shouldn’t be a deterrent. CSS resets can range anywhere from 1-10KB extra into your stylesheet. I feel it’s worthwhile because you now have a tightly-knit page that should appear identical in almost every browser.

Another reason not to use CSS resets would be the obfuscated design of generic page elements. By removing all the standard properties you are left with a very basic starting point. Some developers thrive in this simplicity, while others would rather keep everything in its natural state.

If you prefer a homogeneous design without stripping out the basic CSS properties I would recommend a more detailed framework such as Normalize or Twitter Bootstrap. Normalize is meant to be a reset which provides simple formatting instead of bare bones whitespace – Bootstrap takes this to another level with predefined CSS classes and JS components.

bootstrap v3 library getting started page

I want to state that using any simple browser unification CSS will save you a lot of development time. If you’re hesitant just try out samples on a new web project to see how it works. Bootstrap is perfect for beginners and comes with some easy-to-read documentation. Once you have a framework that you enjoy using it gradually becomes apart of your daily workflow.

Sample CSS Codes

There are so many libraries to mention for CSS resets. If you’re nervous to get started I must highly recommend Twitter Bootstrap – even though it isn’t a true reset library you can learn more about the benefits of consistent page elements.

Many developers will create their own CSS resets built from a template of existing code snippets. I created my own resets from Eric Meyer’s sample and have been updating the snippet every-so-often. If you want something easier try removing the default margin/padding properties from all elements with this code:

* { margin: 0; padding: 0; }

There are more efficient ways to handle resets, but when just getting started you should play around as much as possible. Try to understand the purpose behind each declaration and how this affects various web browsers.

Another sample you might try is the HTML5 reset stylesheet on HTML5 Doctor. It goes more into detail regarding specific page elements. For example if we wanted to support the old deprecated italic/bold tags I would append these lines into my stylesheet:

b,strong { font-weight: bold; }
i,em { font-style: italic; }

This is just a small example but it demonstrates my point accurately. The more time you spend building websites, the more you’ll run into these problems such as font styling and layout positioning. If you save code snippets in your development IDE it’ll be easier to generate your own CSS resets and customize them for each new project.

Advancing Trends

SASS and other similar technologies allow developers to create templates and variables within CSS. You compile resets and stylesheets for individual projects at will, based on what you need for the layout design. I feel we are nearing the dawn of a new age for the web design industry. Powerful innovation coupled with newer technologies may provide a more uniform method for building superb websites.

css resets library open source webpage webapp 2013

Please take a look at CSS Reset whenever you get the chance. It contains a small compilation of the most popular CSS resets and libraries for getting started. You can also read through their helpful CSS tutorials to learn about resets and other web design techniques.

Beyond this point you may find yourself captivated with CSS libraries. Open source code has become very popular amongst developers because we all learn & share together as a community. Take this opportunity to read through some other posts and familiarize yourself with CSS resets, CSS UI libraries, and prototypical browser resets for a cleaner default layout.

Related Articles

Closing

There is no absolute right or wrong answer when it comes to browser resets. Each developer will have his or her own procedure which gets the job done. CSS resets can save you a lot of time matching a duplicate experience for each web browser. Just keep in mind these resets may not be necessary for every website and you should begin to understand the purpose of individual CSS libraries over repeated use.


Advertise here with BSA

December 11 2013

18:04

HTML, CSS, PSD and More: 25 Free Design Resources from November 2013


  

Hello world! Another month has passed and here we are, back again with another collection of the most awesome fresh and free design resources we were able to dig up. We’ve put together a set stuffed with HTML, CSS and PSD templates and added the best UI kits. One important information before you read on: All the following elements are freely usable, though some will require a registration to download.

December 03 2013

15:01

Colorpeek, Part 2: Building Your First Chrome Extension

The following is a guest post by Tyler Sticka. Tyler created a tool called Colorpeek. Yesterday we looked at the what and why of things. Today we'll look at how he built the Chrome Extension, which will serve as a great tutorial on how you can get started building your own Chrome Extensions.

In Part One I showed off Colorpeek, a web app I made for quickly sharing CSS colors, and its Chrome extension, which made receiving colors just as easy. So how’d a guy who describes himself as a designer first and a developer second manage to build a fancy-schmancy extension all by himself?

(Apologies to IKEA.)

Pretty easily, it turns out. Chrome extensions are mostly JavaScript, and relatively simple JavaScript at that. Spelunking through all that documentation, may be harrowing at first, but once you’ve mastered the basics, you’ll find that Chrome development is just web development with a few unique twists.

In this post we’ll build our own miniature version of the Colorpeek extension: background-colorpeek, a tool for finding and previewing all the background-color values that a webpage uses. You’ll be surprised how little rocket science is involved.

What You’ll Need

  • Google Chrome.
  • Your favorite text editor.
  • A folder where the extension files will live.
  • An icon for the browser action, which is Chrome-speak for a button in the browser toolbar. This should be a 19 square pixel PNG. You can use this one if you’d like:

You can create all the files we’ll need now or as we move along... it’s really up to you. By the time we finish, our folder will look something like this:

  • event.js
  • icon19.png
  • inject.js
  • manifest.json

Ready? Let’s get started!

The Manifest File

Create a new file at the root of your folder and name it manifest.json. The manifest is the heart of any Chrome extension. It tells Chrome “here’s what I am, and here’s what I need to work.”

Let’s add some details to the file using JSON:

{
  "manifest_version": 2,

  "name": "background-colorpeek",
  "version": "1.0",
  "description": "Get every background-color from the current tab.",

  "browser_action": {
    "default_icon": "icon19.png"
  },

  "background": {
    "scripts": ["event.js"],
    "persistent": false
  },
  
  "permissions": ["<all_urls>"]
}

Most of these properties are self-explanatory, with a few exceptions:

  • manifest_version: This lets Chrome know what version of the manifest file format we are using. Version 1 was deprecated as of Chrome 18, so you should always use 2.
  • background: Information about the scripts our extension requires to respond to things like a click of the browser action. More on this later.
  • permissions: Because we want our extension to grab the background-color values from any URL, we need permission to interact with &lt;all_urls&gt;. If we wanted our extension to only work on http://css-tricks.com/, we could specify that instead.

There’s a lot more you can do with the manifest file, but that’s all our extension will need.

Script Gets Real

You’ll notice our manifest references a JavaScript file we haven’t created yet, event.js. Create it now, and let’s add some code to it:

// This function will eventually contain some logic
// for receiving background-color values from the
// current tab.
function getBgColors (tab) {
  // But for now, let's just make sure what we have so
  // far is working as expected.
  alert('The browser action was clicked! Yay!');
}

// When the browser action is clicked, call the
// getBgColors function.
chrome.browserAction.onClicked.addListener(getBgColors);

This script is what’s known by Chrome (somewhat confusingly) as an event page. This means it will only run when an event the extension cares about occurs... in this case, the browser action being clicked.

Before we continue, we should load our extension in Chrome:

  1. Open up chrome://extensions/ (or click the rightmost menu button, then “Tools,” then “Extensions”).
  2. Make sure the “Developer mode” box in the upper-right is checked.
  3. Click “Load unpacked extension...” and select the folder you created earlier.

If all goes well, the extension should install like any other. Give the browser action (our icon) a click to see a wondrous alert:

Alert: The browser action was clicked! Yay!

Neat, huh?

Tab Talkin’

Now that our browser action is prepared to do our bidding, we need to retrieve CSS information from the current tab. To do that, we should understand a little about how Chrome extensions work relative to webpages loaded in tabs, and how the two can communicate.

Chrome was the first browser to popularize something we take for granted in desktop browsers today: The multi-process architecture. In Chrome, every webpage, add-on and extension gets its own process. This makes it really difficult for a single webpage or extension to crash your entire browser. But it also makes our event page a bit of an island... how do we act on the contents of a tab when that tab’s process is completely separate from event.js?

Bad news: We can’t.

Good news: We don’t need to, because Chrome supports passing messages between scripts. We already have our event page, which we can use to send messages. All we need now is a script in the current tab that can receive them!

Author’s rendition of sendMessage in action.

Here’s how our nifty message-passing will work:

  1. When a user clicks the browser action, event.js will inject a new script into the current tab with instructions on what to do next.
  2. The injected script will do whatever it needs to, responding with the data we requested.

This means our extension will need one more file, inject.js:

// This helps avoid conflicts in case we inject 
// this script on the same page multiple times
// without reloading.
var injected = injected || (function(){

  // An object that will contain the "methods"
  // we can use from our event script.
  var methods = {};

  // This method will eventually return
  // background colors from the current page.
  methods.getBgColors = function(){
    var nodes = document.querySelectorAll('*');
    return nodes.length;
  };

  // This tells the script to listen for
  // messages from our extension.
  chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
    var data = {};
    // If the method the extension has requested
    // exists, call it and assign its response
    // to data.
    if (methods.hasOwnProperty(request.method))
      data = methods[request.method]();
    // Send the response back to our extension.
    sendResponse({ data: data });
    return true;
  });

  return true;
})();

Now we have a script that’s ready to receive commands and return data. Let’s update event.js to take advantage of that:

// Execute the inject.js in a tab and call a method,
// passing the result to a callback function.
function injectedMethod (tab, method, callback) {
  chrome.tabs.executeScript(tab.id, { file: 'inject.js' }, function(){
    chrome.tabs.sendMessage(tab.id, { method: method }, callback);
  });
}

function getBgColors (tab) {
  // When we get a result back from the getBgColors
  // method, alert the data
  injectedMethod(tab, 'getBgColors', function (response) {
    alert('Elements in tab: ' + response.data);
    return true;
  });
}

// When the browser action is clicked, call the
// getBgColors function.
chrome.browserAction.onClicked.addListener(getBgColors);

Reload the extension from chrome://extensions/ and try the browser action on any webpage. You should see a message with the number of HTML nodes therein, which means we’ve successfully interacted with the tab! Woo-hoo!

Finally Doing Something Cool

All the pieces are in place. It’s time to actually do what we set out to do:

  1. When the browser action is clicked, determine all the background-color values of the current tab.
  2. Build a Colorpeek URL based on those values.
  3. Open that URL in a new tab.

There’s very little magic from this point forward... it’s really just JavaScript (and not even fancy jQuery). Here we go...

Open inject.js again and update the getBgColors method:

// Return all of the background-color values
methods.getBgColors = function(){
  // Stores the colors and the number of occurrences
  var colors = {};
  // Get all the nodes on a page
  var nodes = document.querySelectorAll('*');
  // Instantiate variables we'll use later
  var node, nodeArea, bgColor, i;

  // Loop through all the nodes
  for (i = 0; i < nodes.length; i++) {
    // The current node
    node = nodes[i];
    // The area in pixels occupied by the element
    nodeArea = node.clientWidth * node.clientHeight;
    // The computed background-color value
    bgColor = window.getComputedStyle(node)['background-color'];
    // Strip spaces from the color for succinctness
    bgColor = bgColor.replace(/ /g, '');
    // If the color is not white or fully transparent...
    if (
      bgColor != 'rgb(255,255,255)' &&
      !(bgColor.indexOf('rgba') === 0 && bgColor.substr(-3) === ',0)')
    ) {
      // ...set or override it in the colors object,
      // adding the current element area to the
      // existing value.
      colors[bgColor] = (colors[bgColor] >> 0) + nodeArea;
    }
  }

  // Sort and return the colors by
  // total area descending
  return Object.getOwnPropertyNames(colors).sort(function (a, b) {
    return colors[b] - colors[a];
  });
}

We’re almost done! Now update the getBgColors function in event.js:

// Get background-color values from the current tab
// and open them in Colorpeek.
function getBgColors (tab) {
  injectedMethod(tab, 'getBgColors', function (response) {
    var colors = response.data;
    if (colors && colors.length) {
      var url = 'http://colorpeek.com/#' + colors.join(',');
      chrome.tabs.create({ url: url });
    } else {
      alert('No background colors were found! :(');
    }
    return true;
  })
}

Reload the extension and give it a try. If it works, go get yourself a beverage to celebrate your new-found ability to make Chrome extensions!

Some of the background-color values used on CSS-Tricks.

Extra Credit

This extension is just the tip of the iceberg. There are a ton of things you can do with Chrome’s Platform APIs. Here’s some stuff to try if your brain still thirsts for knowledge:

I hope this helped demystify some aspects of Chrome extension development. And if you like what we built together, please give Colorpeek for Chrome a try... I think you’ll dig it. Happy tinkering!


Colorpeek, Part 2: Building Your First Chrome Extension is a post from CSS-Tricks

Tags: Article CSS

November 29 2013

15:13

A Blue Box

A little meme went around CodePen the other night. A Blue Box. I'm not sure how it started, but lots of people started posting code of different ways to draw a blue box. It's weird, it's funny, but it's also rather amazing there is as many ways as there are for doing something so simple.

Let us count the ways:

Pretty wild hey? Surely this isn't a comprehensive collection of methods either (different image formats, dataURI's, etc). Are all of them good to have and know about it? Does this make it intimidating for beginners or can they safely ignore many of them and learn them in time as needed?


A Blue Box is a post from CSS-Tricks

Tags: Article CSS

November 18 2013

07:30

Fall Cleaning Pt. 2: 26 Free Design Resources, Fresh from October 2013


  

Hello global design community!. We are back with another edition of our monthly collection of the freshest design resources. Today, we’ll show you, what October 2013 had to offer. If you know our series already, you know you can expect the best HTML, CSS and PSD templates, as well as UI-kits for your next great web or native app. All of the resources showcased here are fresh, free and easy to download, suitable for experienced and amateur web designers, so be sure to download the ones you love and share them with everyone you know!

November 15 2013

10:00

Build a Super Easy CSS Slider With Thumbnails

screenshot

Today’s project is another exploration of the types of practical applications that you can achieve with a little ingenuity and some fairly basic CSS. You’ll be blown away by how much you can achieve with just a few lines of code.

The final result with be a great way to display a strip of small image thumbnails that the user can hover to see larger images. Let’s dive in and see how it works.

The Concept

The basic layout here is pretty simple. We want a strip of thumbnail images and one large featured image. The tricky part is getting the featured image to change when the user hovers over one of the thumbnails.

screenshot

Sneak Peek: Click here to launch the finished product.

With CSS, you can’t create two distinct divs and then have the contents of one serve as an action point for the other. It’s easy enough in JavaScript, but CSS gives you less freedom in the way that you stack your selectors.

However, if we’re clever about how we structure our HTML, this project is actually fairly simple to pull off. Let’s see what this looks like.

The HTML

To make this work, we’re going to need four thumbnail images and four full size images. The key to having the former act upon the latter is to wrap them up together like so:

</ br>

Here we have one anchor that surrounds both the small and the large image, and I’ve assigned a specific class to each. This will make it so that when the user hovers over one image, we can easily manipulate the other. We’ll see how all this works when we get to the CSS.

Now that we know how our page needs to be structured, we can repeat this pattern four times and throw it all into a container.

</ br>

Notice that I finished off with a single large image. The reason for this is that the big images will slide into place on hover, leaving a big empty space when nothing is being hovered over. To fill this spot, I created a custom image:

screenshot

This is all the HTML that we’ll need, now it’s time to jump over and style this sucker.

Container Styles

In your CSS file, create a style block for the container. We start by setting its position to relative. We’re going to use absolute positioning later and setting the container to relative positioning will give us a boundary to work with.

After that, set the height and width to the value shown below. These aren’t arbitrary mind you but have been carefully calculated. Each thumbnail image is 200px wide, times four equals eight hundred, plus margins (4*40) equals 960px. Similarly, the thumbnails are 200px high, the big image is 400px and there will be 30px of margins for a total 660px high.

.container {
  position: relative;
  height: 660px;
  width: 960px;
  overflow: hidden;
  margin: 0 auto;
}

</ br>

The reason we’re setting a specific height and width is so that we can slide an image out of the bounds of the container and have it be hidden. To this end, we also apply an overflow value of hidden and finish up by centering it all with auto margins.

Progress Check

We’re looking pretty rough at this point, but don’t worry, everything is right on track!

screenshot

Position Everything

As you just saw in the screenshot, your images are going to be all over the place at this point so now it’s time to coerce everything into its proper position.

Once again, this takes a little bit of hard thinking. We want all our thumbnails to group together and all of our big images to group together, but that’s not how the HTML is structured.

Given that each type of image (small and large) has its own class though, we can float all of our anchors to the left, and then separate out the large images by applying absolute positioning.

.container a {
  float: left;
  margin: 20px;
}

.big {
  position: absolute;
  top: 260px;
  left: 20px;
}

</ br>

It’s very important to understand how this works so let’s run through it. Floating our links to the left made all of the images appear inline, one right after another. However, the absolute positioning on the big images pulls them out of this flow and places them specifically in the spot that we’ve designated using the top and left properties. This leaves only the thumbnail images to be floated.

Progress Check

With very little code we were just able to transform our mess of images into a nicely arranged layout. Note that you’ll only see one large image at this point because the others are stacked under it.

screenshot

Bring It To Life

Now that everything is in place, it’s time to make it work. The first thing that we want to do is move all of the big images except our featured cover out of the bounds of the container. This involves taking a step back and revising some of our previous code.

Go back and set all of the big images to be 900px from the top. This will push them outside of the bottom of our container. While you’re in there, you should also set up a transition. Target the top property and set the transition duration to one second and the timing function to ease.

.big {
  position: absolute;
  top: 900px;
  left: 20px;

  -webkit-transition: top 1s ease;
  -moz-transition: top 1s ease;
  -o-transition: top 1s ease;
  -ms-transition: top 1s ease;
  transition: top 1s ease;
}

</ br>

This code pushes all of the big images out of bounds, including our cover image. Use the code below to bring this back.

.featured {
  top: 260px;
  left: 20px;
  z-index: -3;
}

</ br>

Here we used the top and left values that we had established before to fix the cover to one spot. The z-index value ensures that this image will remain on the bottom of the stack. If we don’t do this, we won’t even be able to see the other images when they slide in!

Hover Styles

Now that we’ve placed all of the big images outside of the container, we need to bring them back when the user hovers. This is accomplished by targeting the big images and returning the top property to 260px. I also added a shadow effect to the thumbnails so you can see the hover taking effect.

a:hover .thumb {
  -webkit-box-shadow: 0px 0px 15px rgba(0,0,0,0.5);
  -moz-box-shadow: 0px 0px 15px rgba(0,0,0,0.5);
  box-shadow: 0px 0px 15px rgba(0,0,0,0.5);
}

a:hover .big {
  top: 260px;
}

</ br>

Because of the way we set up our HTML, each thumbnail automatically corresponds to its accompanying big image. So even though we’re hovering over the thumbnail, the browser sees it as all one anchor and doesn’t mind manipulating only the part with the big class applied. Pretty neat right?

See It In Action

With that, we’re all finished with our awesome slider. Take a look at the live demo below and hover over the thumbnails to give it a test drive. To showcase the versatility of this project, I included two alternate versions in the demo that implement slightly different animations. Be sure to check them out as well.

Demo: Click here to launch.

screenshot

Conclusion

If you were paying close attention, you learned a lot of stuff in this tutorial. First, we overcame the challenge of how to use one piece of an HTML document to act upon another using only CSS, which is no small feat. In addition to this, we learned some cool positioning techniques and even dabbled a bit with manipulating the image stacking order via z-index.

If you liked this tutorial, leave a comment and let us know. Do you have any other uses for remote hovers like we used here? I want to hear them!

Tags: CSS

November 08 2013

10:30

Build a Freaking Awesome Pure CSS Accordion

screenshot

Who has two thumbs and loves to push the bounds of CSS? This guy. Let’s jump into a project that does just that. It’s pretty experimental and won’t pass the semantic police, but it’ll teach you a heck of a lot about advanced CSS tactics and will be tons of fun.

What we’re going to build is a pure CSS horizontal accordion slider. You’ll be able to insert as many slides as you want, each with unique content and each accessible via a click event, all without a lick of JavaScript. Impossible you say? Never!

What We’re Building

The end product of today’s efforts will be a sliding, animated and clickable horizontal accordion menu. We want a few narrow bars that, when clicked, expand to show hidden content.

Demo: Click here to launch.

screenshot

Clickable CSS

As you well know, CSS doesn’t support click events, so how in the heck are we going to get this thing to move from slide to slide? We could take the easy way out and use a hover, but where’s the fun in that? Instead, let’s try something a little more difficult and hijack a set of radio buttons.

With radio buttons, we have everything we need: a group of clickable items where only one can be selected and that selected item is easy to target and style. Perfect! Semantic? Not quite… If you want to do this in a way that’ll hold up under a peer review, use JavaScript. Today we’re simply pushing CSS as far as we can make it go to see if we can learn anything along the way.

Step 1: HTML Frame

Building a new web design project is like building a house. The first step is to get a basic but solid frame in place upon which you can build the rest. To accomplish this, we’ll lay down some starter HTML.

The first thing that we need is an unordered list inside of a form element. This seems a little weird at this point, but it’ll make more sense in a minute.

<form>
  <ul>
    <li></li>
    <li></li>
    <li></li>
  </ul>  
</form> 

Here each list item represents a slide. If you want five slides, you should have five list items. Our test project will use three slides. So why the form element? Let’s attack that next.

Inside of each list item, we’re going to place three elements: an input, label and div. The inputs will be radio buttons, which are attached to labels. Together, these two items will make up our accordion controls. The div will hold the content that we want inside of each slide.

<form>
  <ul>
    <li>
      <input id="rad1" type="radio" name="radio">
      <label for="rad1">1</label>
      <div class="accslide">
      </div>
    </li>
    <li>
      <input id="rad2" type="radio" name="radio">
      <label for="rad2">2</label>
      <div class="accslide">
      </div>
    </li>
    <li>
      <input id="rad3" type="radio" name="radio">
      <label for="rad3">3</label>
      <div class="accslide">
      </div>
    </li>
    </ul>  
</form>

As I mentioned above, we’re using radio buttons here because they provide all of the functionality that we need to pull off this little feat. The problem of course is that they look like radio buttons. We can fix this though with the magic of CSS.

Step 2: Override the Form Styles

Our next challenge is to make ugly radio buttons pretty. Here’s what our HTML will look like without any styling:

screenshot

As you can see, between the list bullets and the radio buttons, we’ve got our work cut our for us. First things first though, before we do anything else, let’s toss out a lazy man’s reset:

* {
  margin: 0;
  padding: 0;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

This makes sure our margins and padding will work right across various browsers and that any padding won’t interfere with our explicitly stated dimensions. Border-box does this by manipulating the standard CSS box-model to be a little more user-friendly.

Clear the List Styles

Next, let’s tackle something easy. Those bullet points can be killed with a simple style block that I’m sure you’re familiar with.

/*LIST*/
ul {
  list-style: none;
}

Hide the Radio Buttons

Now it’s time to target the radio buttons and kick them off of the screen. To do this, we’ll simply set their position to absolute and then place them far away.

/*FORM*/
input {
  position: absolute;
  top: -9999px;
  left: -9999px;
}

Note that my selector here is super generic. If you’re placing this object into any project, make sure that you don’t target all inputs the way I’ve done here. Toss the entire thing into a div with a class and target only the inputs associated with that class.

Style the Label

Now our radio button is hidden, but why the heck did we decide to do that? How are we going to control the accordion? The answer of course is that a radio button’s label serves as an alternate click point and can be styled more freely. This means that even with the radio button gone, our functionality will still be present in the labels, all we have to do is make them presentable.

label {
  display: block;
  float: left;
  height: 330px;
  width: 50px;
  margin-bottom: 10px;
  overflow: hidden;

  background: #999;
  text-align: center;
  font: 14px/50px Helvetica, Verdana, sans-serif;  

  -webkit-transition: width 1s ease, background 0.5s ease;
     -moz-transition: width 1s ease, background 0.5s ease;
       -o-transition: width 1s ease, background 0.5s ease;
      -ms-transition: width 1s ease, background 0.5s ease;
          transition: width 1s ease, background 0.5s ease;
}

Here I’ve split my code up into three chunks so that we can walk through it easily. The first chunk governs the form factor of the label: it’s height, width, margin, overflow, etc. We’ve basically turned the labels into big rectangles that will sit right next to each other.

Next is the chunk of styles that governs the appearance of the labels. We’ve set the background to gray, center-aligned the text (the little numbers) and set the font size.

Finally, we set up some transitions so that the changes that we’re going to make later on will be animated.

Step 3: More Label Styling

With that last chunk of styling, we’ve completely transformed our boring old radio buttons into something that looks a lot closer to what we’re looking to achieve.

screenshot

I don’t like that there’s no definition between the three tabs though, so let’s help this along with a little more styling.

#rad2 + label {
  background: #888;
  -webkit-transition: width 1s ease, background 0.5s ease;
     -moz-transition: width 1s ease, background 0.5s ease;
       -o-transition: width 1s ease, background 0.5s ease;
      -ms-transition: width 1s ease, background 0.5s ease;
          transition: width 1s ease, background 0.5s ease;
}

label:hover, #rad2 + label:hover {
  background: #232323;
  color: #fff;
  cursor: pointer;
}

Here we’ve darkened the second tab so that it stands out between the first and third tabs, added another transition, and set the hover styles to darken the tabs even further when the user mouses over them. This will make our tabs look much better:

screenshot

Step 4: Slide HTML

Now that we’ve got our tabs looking the way we want, let’s jump back and finish out our HTML. This content would’ve gotten in the way if we had inserted it before, but it should stay hidden now.

<form>
  <ul>
    <li>
      <input id="rad1" type="radio" name="rad">
      <label for="rad1">1</label>
      <div class="accslide">
        <h2>Slide 1</h2>
        <p>Lorem ipsum...</p>
        <img src="http://lorempixum.com/420/200/city/1" alt="">
      </div>
    </li>
    <li>
      <input id="rad2" type="radio" name="rad">
      <label for="rad2">2</label>
      <div class="accslide">
        <h2>Slide 2</h2>
        <p>Lorem ipsum...</p>
        <img src="http://lorempixum.com/420/200/city/2" alt="">
      </div>
    </li>
    <li>
      <input id="rad3" type="radio" name="rad">
      <label for="rad3">3</label>
      <div class="accslide">
        <h2>Slide 3</h2>
        <p>Lorem ipsum...</p>
        <img src="http://lorempixum.com/420/200/city/3" alt="">
      </div>
    </li>
    </ul>  
</form> 

Basically, all I’ve done here is inserted a headline, paragraph and image into each slide. Feel free to use whatever content you wish, you can even vary the type of content per slide. Go nuts!

Step 5: Style the Slides

Almost finished! This is our fifth and final step. All we need to do is style up our slide content and then make sure that we widen the slide that is currently selected to reveal the hidden content. Let’s get to it.

Slide CSS

Our slide CSS is a lot like the tab CSS that we used before. If we float these as well, each tab will sit right next to its tab partner, you just won’t be able to see it because its with will be set to 0px.

/*SLIDES*/
.accslide {
  display: block;
  height: 330px;
  width: 0px;
  padding: 10px 0;
  float: left;
  overflow: hidden;

  color: #333;
  background: #fff;
  font: 12px/1.5 Helvetica, Verdana, sans-serif;
  
  -webkit-transition: all 1s ease;
     -moz-transition: all 1s ease;
       -o-transition: all 1s ease;
      -ms-transition: all 1s ease;
          transition: all 1s ease;
}

.accslide p, h2, img {
  width: 420px;
  padding-left: 10px;
}

.accslide img {
  margin-top: 10px;
}

As you can see, I’ve pushed and padded things around a bunch just to make sure everything looks right. Start here, take a look and then customize things to the way you’d like.

Expand When Selected

All this effort and the dang thing still doesn’t work yet! In fact, it doesn’t really do anything. Fortunately, our transitions are in place and everything is perfectly styled, so as soon as well tell the browser to expand the width of the slide when a given label is selected, we’ll be all finished.

This is by far the fanciest bit of CSS in the tutorial. That being said though, you won’t believe how simple it is to bring this whole thing to life:

input[type="radio"]:checked ~ .accslide {
  width: 450px;
}

That’s it! This is all the CSS we need to take our accordion from static to functional. So what’s going on here? I know that selector seems pretty mind-blowing, but it’s not as crazy as you think. Here’s a breakdown:

screenshot

As you can see, what we’re doing is targeting the .accslide class, but if we did this alone we’d expand all of the tabs. What we do instead is select only the items with the .accslide class that are general siblings of the checked label. This way, only the tab that is partnered with the checked label will be expanded.

The funny little swoosh is the general sibling combinator, which looks for a sibling anywhere after the stated element.

Try it Out!

Congratulations, you’re all finished! Now let’s give this sucker a test drive. Click around on the various tabs to see content hidden and revealed.

Demo: Click here to launch.

screenshot

Browser support here should be half way decent. It works great on modern browsers, and we’re not using anything that IE8 and above should get too upset about: a few transitions, box-sizing, and a fancy selector. If you run into problems with IE, try tossing in Selectivizr.

Conclusion

There you have it, with a little ingenuity and elbow grease, we’ve built a pretty fancy interactive element using nothing but HTML and CSS. If you’re open to the idea of hijacking either checkboxes or radio buttons, a lot of crazy stuff becomes possible! Leave a comment and let me know what you think. What would you have done differently?

Tags: CSS

November 04 2013

07:30

October 25 2013

10:00

October 22 2013

16:43

30 Fresh Websites with Modern, Clean Design

So much is possible these days in web design with CSS3, jQuery 2.0, etc, which is why so many websites include animated imagery. You can design a website with all of the bells and whistles and it can still be mobile-friendly, most of the time.

However, my favorite designs still tend to be the ones that have a clean, modern look to them. Clean design doesn’t necessarily mean minimalist, although many are to a certain degree. A clean website often has simple navigation and well-organized elements on a page. The content is easy to read, find, and browse. Some clean websites include minimal animation. Many have a single page design, while many more include several pages, all with a clean look and feel.

What do I define as both clean and modern? By modern, I included the latest trends of this year. Parallax scrollling, full-page images, retro illustrations, and creative typography are all modern trends you’ll find in the collection below.

Very often, a clean design is used by design agencies, freelancers, photographers, artists, bloggers, and other creatives with limited content. The amazing feat is when a website with tons of content is cleanly designed. The list of modern, clean website designs include those with brief content and a few of the awe-inspiring ones with a plethora of content organized incredibly well. Keep in mind that for many of these, you will need to visit the site to get the full affect.

Playful – New Finnish Design

Marmoset

Zinio

Layer

Creative Mornings

PRSM

Refryed

Ditto

Kiawah Island Real Estate

Spacho

National Traveller

The Amazings

Seattle Cider Company

Nowhere Famous

Break It Down

Mulberry

Molly & Me Pecans

Vox Media

Toast

Kaus

Pigeon

HypeJar

Doylestown Ride

Kluge

Lore

Jim’s Scarf Project

Nuvo Magazine

Green Plant Swap

Run the Gap

Whoa Nelly Catering

06:30

Bento: One-Stop Shop for Online-Courses on Web Development


  

It’s merely a few weeks ago, that we brought you a comprehensive overview of 22 of the online learning resources the planet has to offer. Just today we stumbled upon another effort for web designers, developers and programmers. An offering by the name of Bento curates the best learning resources in its field. The collection is community-based and as such more helpful than any Google search result could ever be ;-)

October 18 2013

12:20

5 Steps to Drastically Improve Your CSS Knowledge in 24 Hours

screenshot

You’ve been coding for a while now and know your way around a CSS file. You’re certainly no master, but with enough fiddling you can get where you want to go. You’re wondering though if you’ll ever get past that point where CSS is such a struggle. Will you ever be able to bust out a complex layout without ultimately resorting to trial and error to see what works and what doesn’t?

The good news is that you can indeed get past that frustrating point where you know enough CSS to code a website, but lack the solid foundation that allows you to code without the annoyance of not exactly understanding how you’re going to get where you’re going, and this point is a lot closer than you think. I propose that there are five topics that will drastically boost your understanding of CSS. Spend some time reading about each over the next twenty-four hours and you’ll change the way you code forever.

1. Wrap Your Mind Around Positioning Contexts

screenshot

If you really want to have a solid understanding of how to use CSS to move HTML elements to where you want them to go, you absolutely must get a grip on positioning contexts. And I don’t just mean a casual understanding, I mean a deep knowledge of their differences, behaviors, quirks, etc.

There are actually five position values that you should understand. If you can’t name all five without looking them up, then you’re definitely a prime candidate for this bit of education. Here they are: static, fixed, relative, absolute and inherit.

You need to know and understand all five, but the big two that will really change the way you code are absolute and relative positioning. Learning to wield these two positioning contexts separately, and then jumping into how they work together, will fundamentally change the way you view CSS layout, I promise. It’s a revelation that will make your job infinitely easier.

Resources To Get You There

The Lowdown on Absolute vs. Relative Positioning
This is my deep dive into the subject of positioning context. I briefly mention and explain all five but really focus in on the big two: how they differ, how they’re different and how they work together. Read through this piece and you’ll be well on your way to headache free CSS positioning.

CSS Positioning 101
This piece comes from the venerable A List Apart blog so right away you know that it’s going to be both thorough and incredibly educational. The article was published back in 2010 but the information is still perfectly relevant and it serves as a great introduction to all five positioning contexts. It’s not a very visual article but it does have lots of simple code examples to ease you into each concept.

Learn CSS Positioning in Ten Steps
This is a fantastically brief overview of the various positioning contexts. Instead of one long winded article, this page presents a little box with ten tabs. Each tab has a tiny code snippet and a sentence or two explaining the code. Off to the right is a live example layout that updates with each tab. This format is fantastic for visually linking code snippets to the layouts they produce and I highly recommend giving it a look if you struggle with mostly text explanations like the one above from ALA.

2. Master Floats

screenshot

When you’re first learning CSS, floats seem like one of the most screwed up layout systems imaginable. Once you learn to use them on a basic level, you then have to learn all about how parents containing only floated children have a collapsed height, which then leads to forty-seven different ways to solve the problem through clearfixes and overflow manipulations.

Fortunately, in the long run, you do get used to the concepts behind floats and they can even become so easy to use that you don’t give them much thought at all. The only thing standing between you and that goal is a solid article or two that really digs in and thoroughly explains float behavior and techniques from the ground up.

Resources To Get You There

Everything You Never Knew About CSS Floats
In this article, I cover nearly the complete gamut of topics regarding floats in CSS. It starts off with a basic discussion of what floats are and how they work. After this, I talk about how floats effect the boxes of the elements involved, how floats get weird with elements of varying heights, the nine rules that cover float behavior and of course the collapsing height debacle and how to fix it.

All About Floats
Chris Coyier has always been my favorite author when it comes to CSS related topics and his introduction to floats doesn’t disappoint. If you’re looking for a brief but straightforward discussion on how to work with floats, this piece has you covered. I particularly like the simple, attractive illustrations used throughout the article.

The Mystery Of The CSS Float Property
While Chris Coyier’s pieces are typically brief and to the point, the content on Smashing Magazine is usually quite expansive with tons of examples and relevant discussion. This article introduces the concept of floats, tells you all about how to use and clear them and then launches into a discussion of where you typically see floats being used in real world sites. If you need to see the theory come alive, this one is for you.

3. Know Your Selectors

screenshot

One of the keys to writing good clean CSS is to have a strong grasp of what CSS selectors are available to you, how they work and the degree to which they are supported on various browsers. It sounds like a simple enough topic, but in reality the world of CSS selectors is quite complex.

There are a ton of different interesting things to learn about here, from using attribute value selectors and targeting keywords in class names to how the universal selector can be helpful for debugging your code. Even if you think you can personally get by without understanding a bunch of fancy selectors, the truth is that other coders use this stuff every day and you need to be able to understand what you’re seeing when you hit view source!

Resources To Get You There

CSS Selectors: Just the Tricky Bits
This is a fun article that takes a look primarily at the more complicated aspects of CSS selectors. I skip the ground level stuff and jump straight into discussing how the concept of the DOM translates to targeting various aspects of your document with CSS. You’ll learn all about selecting children and siblings, how to chain selectors and a lot more.

The 30 CSS Selectors you Must Memorize
Jeffrey Way is a web dev rockstar and articles like this prove why. This Nettuts+ article covers a vast array of CSS selectors in a simple and brief format that places a lot of emphasis on browser support. Amazingly enough, Jeff even coded up live example pages for each of the thirty selectors.

CSS Attribute Selectors: How and Why You Should Be Using Them
Attribute value selectors are one of the most powerful subsets of CSS selectors, and CSS3 really boosts that power. You won’t believe how versatile your selectors can become with a little attribute value magic. After reading this article, you’ll be slinging around phrases like “arbitrary substring attribute value selector” like a pro.

4. Learn DRY Coding Concepts

screenshot

“Don’t Repeat Yourself.” This simple phrase has drastic implications when it comes to coding. When you really dive into DRY coding practices, the result is cleaner code, less work and a beautiful new workflow that is as empowering as it is flat out awesome.

Unlike the other topics above, which are fairly narrow, this one is a pretty vast subject that covers all manner of different practices, techniques and ideas. Interestingly enough, one of the things that has recently gotten my mind focused on DRY coding practices is the use of CSS preprocessors.

Though many claim that preprocessors lead to poor coding practices, the reality is the opposite. Obviously, preprocessors themselves help avoid manual repetition, but it goes beyond that. Examining the output of tools like LESS and SASS and the goals for the languages in general has actually led to me writing better pure CSS! Once you master concepts like @extend in Sass, you can’t help but think about the implications when you’re coding with only CSS.

Resources To Get You There

DRY CSS: Don’t Repeat Your CSS
In this article, Steven Bradley introduces you to the topic of DRY CSS and covers some of its main principles and goals. He boils the practice down to three simple ideas and shows you how to implement these ideas in a real workflow. The concepts are largely borrowed from a Jeremy Clarke presentation covering the same topic.

An Introduction To Object Oriented CSS (OOCSS)
As I mentioned before, the ideas inherent in the DRY CSS movement are pretty far reaching and directly related to concepts in other constructs. OOCS is an increasingly popular methodology that aims to help you create faster, more efficient stylesheets with superior organization and less repetition. There are two main principles at work in OOCS: separation of structure from skin and separation of containers and content. This article from Smashing Magazine will walk you through the basic ideas and help you apply them to your own work.

An Introduction To SMACSS Guidelines For Writing CSS
Remember Steven Bradley from the first article on DRY CSS? He also wrote this piece, which explains a project that’s similar to but separate from OOCS: SMACSS (a project from Jonathan Snook). As with OOCSS, SMACSS has two main goals. The first is to increase the semantic value of a section of HTML and content, and the second is to decrease the expectation of a specific HTML structure. This article explains both goals in detail and provides helpful code examples so you can see SMACSS in action.

5. Know Your Browser Support

screenshot

The fifth and final key to improving your CSS is to know what works where. CSS3 is far too enticing for most of us to ignore, but the hard truth is that a whole bunch of it doesn’t work in certain browsers (by “certain browsers” I of course mean IE).

The big secret that newbie web developers need to get into their heads is not that they need to memorize every single CSS feature and how every browser known to man handles it, instead its that there are absolutely amazing resources available to you that give you this information freely, you just have to know where to look.

Resources To Get You There

Nailing Browser Support in CSS3 and HTML5: Invaluable Resources to Use Today
In this article I introduce you to the relatively few sites that I have bookmarked for checking browser support. These resources are fantastic, visual and give you the information you need in a jiffy so you can get back to coding. Take a look to see what they are!

Browser Support for CSS3: What’s the Current Status?
This article was written over a year ago so the “current status” piece is arguable, but not enough has changed in this time to make the information in this article obsolete. It serves as an incredibly helpful overview of various CSS3 properties, divided into sections based on what works everywhere and what you need to watch out for. It’ll only take you a few minutes to go through and it’s well worth the read.

The Importance of Cross Browser Compatibility: Tips and Resources
If you’re really new to CSS and need a basic introduction to the topic of browser compatibility and why it’s important, this Noupe article has you covered. More than merely selling you on the idea of compatibility, it lists a bunch of great resources that you can use to ensure maximum compatibility. Of particular interest is the list of tools that will help you test your site in various browsers.

I’m Supposed To Read All This in 24 Hours?

screenshot

I’ve presented you with five absolutely critical topics to study up on and no less than fifteen articles from which you can learn the principles that you need to know. This is all well and fine but in my title I promised that you’d get better in a single day and not everyone has the time to sit down and read fifteen long articles!

The good news is that I gave you three articles on each topic so you’d have some variety to choose from. I explained the contents of each in detail so you can select the one that best fits your needs. Remember to choose the articles to read not based on what you do know, but what you don’t know. Make it a goal to fill the gaps in your knowledge.

My suggestion is to browse through the content above and pick five articles to read (one from each section). Even that’s a lot to undertake in a day but most of them aren’t too much more than a thousand words or so, many are less. I’m confident that you can pull it off. If you can’t, no problem. Change your goal to improving your CSS skills in a week and read one of your five chosen articles every day for the next five days. I guarantee that come next week you’ll be much better at writing clear, concise, compatible and reusable CSS.

What Other Concepts Do You Recommend?

Now that you’ve read my top five topics that people should brush up on to improve their CSS skills, I want to hear from you. What other topics do you think CSS coders typically struggle with and what resources do you recommend for anyone looking to learn more?

Stock photos provided courtesy of BigStock

Tags: CSS

October 16 2013

06:30

Colors of Fall 2013: 21 Fresh and Free Design Resources


  

Hello designers, developers, web enthusiasts of the globe. We are back with another edition of our monthly collection of the freshest design resources the month of September had to offer. If you know our series already, you know you can expect the best HTML, CSS and PSD templates, as well as UI-kits for your next great web or native app. All of the resources showcased here are fresh, free and easy to download, suitable for experienced and amateur web designers, so be sure to download the ones you love and share them with everyone you know!

October 15 2013

06:30

One-Stop Shop: PHP-Tool Munee Cares for All your Website’s Assets


  

Cody Lundquist, Australian with a Swedish sounding name, created a free asset-management based on PHP 5.3. Its feature-set is astounding, yet demands a special preliminary treatment of the websites, it’s supposed to be working on. Munee is able to manage any kind of possible asset, be it images or other files, JavaScript, CSS, LESS, SCSS or even CoffeeScript.

Older posts are this way If this message doesn't go away, click anywhere on the page to continue loading posts.
Could not load more posts
Maybe Soup is currently being updated? I'll try again automatically in a few seconds...
Just a second, loading more posts...
You've reached the end.

Don't be the product, buy the product!

Schweinderl