10 Useful CSS Snippets Every Designer Should Have

10 Useful CSS Snippets Every Designer Should Have

Just Creative is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission at no extra cost to you. As an Amazon Associate we earn from qualifying purchases. Learn more

This article was contributed by Rajeesh PK.

Designers and developers should always be looking out for tricks and hacks that help them develop their process in-line with browser support.

sponsored message

Adobe Creative Cloud Discount

You can use some of these CSS snippets to automatically adjust the specifications of the columns in your table, wrap long text or even create a simple loading state without using GIFs.

1) Align anything vertically

This is one of the scenarios that designers who work with CSS face most often – we all wanted help with text alignment or element alignment vertically at least once! Using CSS3 Transforms, this can be easily sorted out.

Find the snippet provided below, which you can use the next time you are stuck.

With this, you can bring about a vertical alignment across boxes, single lines of text, paragraphs. And, you can easily find browser support for Firefox 3, Chrome 4, Opera 10, Internet Explorer 9 and Safari 3.

2) Stretch elements to fit into the full height of a window height

There might be scenarios when you would want to expand your components to fit into the exact height of your window. With the basic element resizing, you can resize to fit into the container size. But, if we want to resize a component to the size of a container’s full window height, then we need to start from the elements, such as html and body.


sponsored message



Here, is how to:

Let us then apply 100% height to the specific component and:

3) Apply different styles to different file formats

Sometimes it is not easy to identify where a link is moving to, in such situations, you wish that that these different links would appear different from one another. Here you can find a snippet which will add icons to the link text and also insert icons above the link text. It will use a variety of icons or images for different sources.

4) Grayscale images with cross browser support

sponsored message


If you want your website to appear more classic and even minimalistic, you can use Grayscale that will splatter a brighter and in-depth tone. Here is an example on how to apply grayscale filters to images using SVGs. Many of you might have already used this.

If you want this to be rendered across cross browsers, use the ‘filter’ property as given below.

5) Animate backgrounds in gradient

Have you ever thought of a life without animations? It is difficult to imagine. So, let us find out how the animation feature of CSS can help you with this. It is believed that this gradient is one of the best that CSS offers. It is possible to animate the opacity, size, and background color with this, but it doesn’t offer gradient colors. Here is a snippet that will help you with this. The background position would be moved to bring about an animation effect.

6) Auto width in table columns

The truth is that none of like playing with tables as they are not easy to deal with while trying to bring about adjustments across the widths of columns. Here, is a shortcut or snippet that will help you. By inserting ‘white-space:nowrap’ within the ‘tdelement’, you can bring about appropriateness in the text wrapping.

7) Display box shadows on any side (one or two)

Here is an interesting snippet that will help you with box shadows on both, or either side of the box. If we want this to be done, the box and its related height and width need to be defined. You can give this shadow using the ‘:after’ pseudo component. Just ensure that it is placed in the right point. This is how bottom-only shadows are created.

8) Wrap text content that is too long

For texts that are longer than their containers, use this simple hack and it will get sorted with ease. The default mode will fill text horizontally, no matter what the width of the container is, as given in the example below:

You can use this snippet to get the text to fall within the width of the container or holder.

Before:

Text Wrap Before

sponsored message


After:

Text Wrap After

9) Blur text in CSS

Do you want to blur your text? Use ‘text-shadow’ for this. All you have to do is use transparent color and then add the text-shadow as given below:

10) Animate ellipsis

The below-given sample shows how you can use snippets to create an animation named as ellipsis, which will further help in generating loading states that are simple – all without using GIF images.

These are just some popular CSS snippets that you can use to bring about changes to your design. Along with CSS snippets, keep yourselves updated with popular CSS frameworks as they are in the constant state of improvement.

About the author: Rajeesh is a Director and Creative Head at Acodez, a leading web development company in India. 

14 thoughts on “10 Useful CSS Snippets Every Designer Should Have”

  1. Hello Jacob! Thanks for sharing wonderful insights and information about CSS Snippets! i am also one of the Jr. Designer, and always looking for updated information about web / graphic designing! But it really helped me a lot! Thanks again jacob!

  2. I don’t know before that images can be gray scaled with css snippets. Great work, thanks for sharing.

  3. What a fabulous post,

    I enjoyed reading your article about what kind of CSS snippest every designer must have and I find it insightful and a great read.

    Anyways, great blog.

Comments are closed.

[Cyber Monday Deals LIVE!]
[Cyber Monday Deals LIVE!]