background preloader

CSS tricks

Facebook Twitter

Free JavaScript / CSS / CSS3 - CSS Script.

CSS Articles

Perfect Icons - A social icon creation tool. CSS Animations. Write Better Media Queries with Sass. Let's face facts: media queries can be a pain.

Write Better Media Queries with Sass

They're difficult to write and they tend to get duplicated a lot. Sass includes a few helpful features that make media queries easier to work with. This article will show you these tricks and how you can use them to simplify your stylesheets. The Basics Let's take a look at a simple example. Here, we've set the font size of paragraphs to 16 pixels.

Right away, you should be struck by how much code is required to do something as simple as responsive typography. Multi-Level Drop Down Menu with Pure CSS3 - Minimal Transparent Menu. Useful :nth-child Recipes. Different Tricks on How to Make Bootstrap Columns All the Same Height. Bootstrap 3 (and now Bootstrap 4) are amazing CSS frameworks that can make the lives of developers of any skill-level easier.

Different Tricks on How to Make Bootstrap Columns All the Same Height

When I was more of a beginner and I first started using Bootstrap, I used every feature of it possible and used to hack it to get things to work the way I wanted. Now, with more experience, I mostly just use their reset and grid system. The 30 CSS Selectors You Must Memorize. So you learned the base id, class, and descendant selectors—and then called it a day?

The 30 CSS Selectors You Must Memorize

If so, you're missing out on an enormous level of flexibility. While many of the selectors mentioned in this article are part of the CSS3 spec, and are, consequently, only available in modern browsers, you owe it to yourself to commit these to memory. And by the way, if you're having trouble with your CSS and want a pro to look over it and fix any errors, you can find some qualified freelancers on Envato Studio.

Let's knock the obvious ones out, for the beginners, before we move onto the more advanced selectors. The star symbol will target every single element on the page. The * can also be used with child selectors. This will target every single element that is a child of the #container div. View Demo IE6+ Firefox Chrome Safari Opera. Sub-Menu Aligned Middle. Animation. The animation property in CSS can be used to animate many other CSS properties such as color, background-color, height, or width.


Each animation needs to be defined with the @keyframes at-rule which is then called with the animation property, like so: See the Pen A simple animation by CSS-Tricks (@css-tricks) on CodePen. Each @keyframes at-rule defines what should happen at specific moments during the animation. For example, 0% is the beginning of the animation and 100% is the end. These keyframes can then be controlled either by the shorthand animation property, or its eight sub-properties, to give more control over how those keyframes should be manipulated.

Sub-properties. Is it possible to transition text-alignment using CSS3 only? CSS Reference - A free visual guide to the most popular CSS properties. CSS3 transition on click using pure CSS. Edit fiddle. Using media queries. A media query consists of an optional media type and zero or more expressions that limit the style sheets' scope by using media features, such as width, height, and color.

Using media queries

Media queries, added in CSS3, let the presentation of content be tailored to a specific range of output devices without having to change the content itself. SyntaxEdit Media queries consist of an optional media type and can, as of the CSS3 specification, contain zero or more expressions, expressed as media features, which resolve to either true or false. The result of the query is true if the media type specified in the media query matches the type of device the document is being displayed on and all expressions in the media query are true. When a media query is true, the corresponding style sheet or style rules are applied, following the normal cascading rules. Unless you use the not or only operators, the media type is optional and the all type will be implied. Logical operators and @media (min-width: 700px) { ... } 10 principles for smooth web animations. There are dozens of ways to achieve animations on the web.

10 principles for smooth web animations

For example, the filmstrip is an approach has been around since before the internet, with slightly different hand-drawn frame being swapped out many times a second to create the illusion of motion. Twitter recently used this simple approach for their new heart animation, flipping through a sprite of frames. This effect could’ve been done with a ton of tiny elements individually animating, or perhaps as an SVG, but that would be unnecessarily complex and probably not be as smooth. In many cases, you’ll want to use the CSS transition property to automatically animate an element as it changes. Inspiration for Button Styles and Effects. A collection of fresh button styles and effects for your inspiration.

Inspiration for Button Styles and Effects

We use CSS transitions and pseudo-elements for most of the effects. View demo Download source Today we’d like to share some fresh button styles and effects with you. The current “button trend” is quite exciting since there are a variety of design details in use which allow for a great diversity of styles. There are lots of thin lines but also bold typography and vice versa. In order to keep things overseeable, we’ve chosen to trigger any effect on hover.

Please note that some of the techniques used are only supported in modern browsers. We use CSS transitions in most cases but we also have a couple of examples with CSS animations. This time, we’ve used a kind of modular approach, where we set certain properties like border-radius, font-size, border, etc. in separate classes so that creating a certain button style becomes more simple. Css - Remove white space below image. Css - Remove white space below image.