background preloader

CSS Tricks

Facebook Twitter

CSS Overlay Techniques. There are several techniques for creating overlays: from using an absolutely positioned element to outlines and pseudo-elements.

CSS Overlay Techniques

In this article we are going to explore each technique's styles with their pros and cons. Design patterns, a set of best practices and techniques that aim to solve some of the most common design “problems”, are usually presented in the context of design principles. One of these design principles is the “Stay On Page” principle.

This principle is based on the fact that page refreshes are disruptive to the user’s mental flow, causing what is known as “change blindness”, and that we need to be able to avoid breaking the visual flow of the user wherever and whenever we can. We can decide intelligently when to keep the user on the page and model his process. Lightweight overlays can be used for asking questions, obtaining input, introducing features, indicating progress, giving instructions, or revealing information. Technique #1: Absolutely positioned element. How To Build A CSS3 Sliding Menu. It’s often best to put things away until you need them.

How To Build A CSS3 Sliding Menu

Navigation menus are a good example. If I’m reading an article, I don’t want a large proportion of screen real estate taken with links — especially on a mobile device. CSS Positioning. Review the W3C CSS standard recommendation.

CSS Positioning

To use CSS for layout effectively, it helps to know how it's used to position page content. This article gives an overview of the methods and rules that govern visual rendering in the CSS2 specification. It also points out some things to watch out for. Although the specification applies to any device for displaying web pages, this article focuses on how it works in browsers. Many details are left out for the sake of simplicity. It's important to remember that a given browser may not support a given feature or may even implement it incorrectly. The Box Model.

CSS Quick Tutorials. Tools & resources for web professionals.

CSS Quick Tutorials

How To Vertically Center Unknown Rows Of Content Inside A Fixed Container. One task css doesn’t make easy is centering objects vertically within their containers.

How To Vertically Center Unknown Rows Of Content Inside A Fixed Container

Last summer I offered 6 methods for vertical centering to address that difficulty. The methods generally require knowing in advance the heights of the parent and child elements. What do you do when the child element’s height isn’t known? A variation of this question was brought to my attention by Manuel who posed it in a comment on the vertical centering post mentioned above. I´d like to ask you about vertical centering a child element with a variable height. My initial thought was Javascript would be needed to determine the total height of the child elements, but I thought why not take a look at each method and see what I could come up with.

6 Methods For Vertical Centering With CSS. Centering elements vertically with css is something that often gives designers trouble.

6 Methods For Vertical Centering With CSS

There are however a variety of methods for vertical centering and each is fairly easy to use. Today I want to present 6 of those methods. I’ve usually skipped over the topic of vertical centering, since there are some good posts already out there that are easy enough to find, but recently Bikram commented requesting a tutorial on vertically centering so I thought why not. You can view demos of each of the methods below by clicking here. Clicking the images above each section will also take you to that specific demo. Let’s start by first talking about something that doesn’t work as many expect. Vertical-Align. CSS-Tricks: Info & Code (Not Just CSS) Snippets. The Secrets Of CSS 3D Transforms. CSS Lists & Counters Module Level 3. Abstract This draft contains the features of CSS level 3 relating to list styling.

CSS Lists & Counters Module Level 3

It includes and extends the functionality of CSS level 2 [CSS21]. The main extensions compared to level 2 are a pseudo-element representing the list marker, and a method for authors to define their own list-styles. CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, in speech, etc. Status of this document This is a public copy of the editors’ draft. The (archived) public mailing list www-style@w3.org (see instructions) is preferred for discussion of this specification. This document was produced by the CSS Working Group (part of the Style Activity). This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. Table of Contents 1 Introduction. Pure CSS Buttons, Hover Effect & Active Pseudo-Element. You may remember the days when we used to lookout for custom image buttons.

Pure CSS Buttons, Hover Effect & Active Pseudo-Element

And for getting the hover and active states, we used to deploy JavaScript codes to change the image on hover and click. But there were issues of loading of three images for each state. Unless the images are loaded, the image used to disappear on mouse hover and click. Well, the days are gone with CSS3 introduction. Most of the websites coming out these days are using the cool buttons created purely with CSS. CSS3 Filters: Altering HTML & Images With Just CSS.

CSS3 Filters are a quite interesting offshoot from SVG, allowing you to modify HTML elements and images with blurs, brightness and a lot more.

CSS3 Filters: Altering HTML & Images With Just CSS

In this quick tutorial we’ll go over exactly how they’re going to work. Using just CSS we can accomplish some pretty complicated effects. These should be applicable to both images and HTML elements, but obviously browsers will vary for the foreseeable future. Inner Shadows In CSS: Images, Text & Beyond. Shadows in CSS are quick and easy, whether you’re slapping on a box-shadow or a text-shadow.

Inner Shadows In CSS: Images, Text & Beyond

But how comfortable are you with inner shadows? Can you pull off an inset box-shadow? How do you do the same thing on some text? Today we’re going to learn some really simple inset shadow techniques that you can pull off with just a few lines of code. I’ll walk you through both the box-shadow and text-shadow syntax and how to change them to pull off an inset shadows. Shadow Syntax Before we jump into inset shadows, let’s look at the basic syntax for building the two different types of CSS shadows. Box-Shadow Box-shadows are probably the most common type of CSS shadows. As you can see, listed above in order, the order of values is horizontal offset, vertical offset, blur radius, spread radius and color.

The latter two values, blur radius and spread radius are a bit more complicated. Animating CSS Shapes With CSS Animations & Transitions. Notes About Current Browser Support for CSS Shapes: The Shapes properties are still in flux at this time. Most of this article's demos use the shape-inside property, which will be temporarily removed from Webkit and Blink. The principles of animating shapes is applicable to both CSS Shapes and CSS Clipping masks. All the demos in this article use clipping masks to visualize CSS Shapes. Hence, the shapes are animated as clipping paths as well. So, you will be able to see the shapes animate in webkit-based browsers at this time, but the content inside the shapes won't be affected by the shapes because of the current state of support for CSS Shapes.