50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)

css-technique-01

50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)

Although CSS is generally considered a simple and straightforward language, sometimes it requires creativity, skill and a bit of experimentation. The good news is that designers and developers worldwide often face similar problems and choose to share their insights and workarounds with the wider community.

This is where we come in. We are always looking to collect such articles for our posts so that we can deliver the most useful and relevant content to our readers. In this post, we present an overview of useful CSS/jQuery coding tips, tricks and techniques for visual effects, layouts and web form design to help you find solutions to the problems you are dealing with or will have to deal with in future.

You may want to look at similar CSS-related posts that we published last months:

CSS Layouts: Techniques And Workarounds

Facebook Style Footer Admin Panel4
Learn how to re-create the Facebook footer admin panel with CSS and jQuery. Also check out part 25.

Css-technique-15 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)4

Adaptable View: How Do They Do It?6
This tutorial explains how to manually change a layout, and it shows two great examples and “how they did it.”

Css-technique-01 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)6

Easy Display Switch with CSS and jQuery7
A quick and simple way to enable users to switch page layouts using CSS and jQuery.

Css-198 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)7

Quick Tip – Resizing Images Based On Browser Window Size8
In fluid layouts, formatting text to adjust smoothly to window size is easy, but images are not as fluid-friendly. This quick tip shows how to switch between two image sizes based on the size of the browser, the DIV or whatever else you choose.

Css-064 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)8

One Page Résumé Site9
A clean layout on one page—literally (just one index.html file with optional images). It comes with contact information in microformats and a main area for the resume using a definition list (dl). And it prints well.

Css-000 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)9

Pegs: Automate Display: fixed++10
Chris Wetherell posts on Pegs, a strategy for having one scroll bar but independent scrolling areas. After the first one, click on the other items to flip between sizes. You will see that an area’s scroll depends on the configuration.

Css-135 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)10

CSS 100% Height11
A common problem among designers is how to get a div to stretch 100% of the window’s height. There are a few different techniques out there, and this tutorial shows one of them.

Css-technique-18 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)11

CSS3 Drop-Down Menu12
A clean, simple a nice navigation menu, designed by Nick La.

Css-technique-21 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)13

CSS Trick for a Scrolling Transparent Background Effect14
Scroll the page to watch a battle between good and evil take shape. The effect requires two images: one transparent and one tiled gradient image. The gradient scrolls under the transparent PNG. Because it matches the colors in the PNG, each set of images disappears, depending on the part of the gradient they’re on top of.

Css-148 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)14

Fluid Images15
By default, an image element that is 500 pixels doesn’t exactly play nice with a container as large as 800 pixels or one as small as 100. What’s a designer to do?

Css-069 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)15

Scroll/Follow Sidebar, Multiple Techniques16
A really simple concept: the sidebar follows you as you scroll down the page. There are a number of ways to go about it. Two are covered here: CSS and JavaScript (jQuery), with a bonus CSS trick.

Css-technique-00 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)16

Vertical Centering With CSS17
There are a few different ways to vertically center objects using CSS, but choosing the right one can be difficult. Here is a list of the best ways and an explanation of how to create a nice centered website.

Css3-new-08 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)17

Create YouTube-like adaptable view using CSS and jQuery18
Other than the “Turn off the lights” feature, YouTube has great stuff, such as the “change view” feature, which allows you to switch between normal and wide mode, thus expanding or shrinking the video area. Creating this is very simple.

Css-142 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)18

How To Create a Horizontally Scrolling Site19
If websites were made of wood, the grain would run up and down. Vertical is the natural flow of the Web. But browsers are equipped with vertical and horizontal scroll bars, right? We have the choice to go against the grain and create web pages that scroll primarily horizontally and that even expand horizontally to accommodate more content. Perhaps a slight blow to usability, but a cool creative touch nonetheless!

Css-technique-02 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)19

Purely CSS – Faking Minimum Margins20
min-margin is non-existent in the CSS world. After you’ve pondered and Googled it, check out the solution here.

Css-technique-03 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)20

Create Sidebars of Equal Height with Faux Columns21
CSS can be tricky business. Creating columns of equal height, where the content in one column is longer than the content in another, is frustrating. Here’s where the faux-column technique can help. Find out how this solution makes even the most complicated layout a breeze to code.

Setting Equal Heights with jQuery22
Here is a script to match the heights of boxes in the same container and create a tidy grid, with little overhead.

Css-141 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)22

Quick Tip: Centered Fake Floats23
There were ways to center-align left-floated elements, but then inline-block became popular and everything changed. After a bit of tinkering, Zaharenia Atzitzikaki found an efficient and (mostly) cross-browser-compatible way to center elements without floats.

6 Flexible jQuery Plugins to Control Web Page Layouts Easily24
A collection of six jQuery plug-ins to manage page layouts easily.

Css-125 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)24

Four Methods to Create Equal-Height Columns25
This article discusses ways to create equal-height columns that work in all major browsers (including IE6). All of the methods show how to create a three-column layout.

Css-065 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)25

How to: CSS Large Background26
A tutorial with various CSS examples for how to create a large background using either a single image or double images.

Css-080 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)26

A Nice Little CSS Positioning Technique27
Here, we have a basic unordered list (ul), with left-floated images where the text doesn’t wrap under the images. Of course, this technique could be deployed in loads of other instances.

Css-117 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)27

Perfect Full Page Background Image28
This technique allows an image to fill the page, with no white space. The image scales as needed and retains its proportions, without triggering scroll bars.

Css-162 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)28

Smart Columns With CSS and jQuery29
In observing liquid-width websites, Soh Tanaka sees two common techniques for displaying columns: fixed columns and liquid columns. He points out the drawbacks of both and pitches his solution.

Css-057 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)29

Images And Visual Effects With CSS

A Beautiful Apple-Style Slideshow Gallery With CSS and jQuery30
Create an Apple-like slideshow gallery, similar to the one used on Apple’s website to showcase products. It works entirely in the front end; no PHP or databases required.

Css-technique-12 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)30

Rolling a coke can around with pure CSS31
Román Cortés is having a lot of fun doing CSS tricks these days. He just built a rolling coke can that uses background-attachment, background-position and a few other tricks to achieve the effect. No fancy CSS3 needed here!

Css3-new-10 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)31

Grayscale Hover Effect With CSS and jQuery32
A few months ago, James Padolsey introduced a cool grayscale technique for non-IE browsers. His technique inspired Soh Tanaka to come up with a workaround with a similar effect. His solution relies on CSS Sprites and a few lines of jQuery, but it requires a bit of preparation before implementation. It is not recommended for large-scale projects; it is probably best for portfolio pieces.

Css-055 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)32

Codename Rainbows33
Some JavaScript and CSS magic is used here to apply a two-color gradient to text. Shadows and highlights can also be applied. This works especially well on big websites and for dynamic content where creating images for every instance would be impractical.

Css-097 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)33

3 Easy and Fast CSS Techniques for Faux Image Cropping34
This article summarizes three fast and easy CSS techniques for displaying only a portion of an image. All of the techniques need only a couple of lines of CSS. You are not literally cropping, which is why it’s called faux image cropping. These techniques can be helpful if you want to keep images to a certain size (for example, thumbnails in a news section). Being able to use CSS to control which portion of an image to display is great.

Css-technique-08 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)34

Image Rollover Borders That Do Not Change Layout35
With CSS, the border of any block-level element is factored into the element’s size in the layout. So, if you add a border to an element on hover, the layout will shift. In this post, you will find how to use the regular border property and create inner borders to get around that.

Css-technique-10 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)35

Horizontal Stripes36
This tutorial shows you how to create never ending horizontal stripes in your web design using CSS.

Css-technique-14 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)36

Nine Techniques for CSS Image Replacement37
Put nine different techniques of image replacement to the test.

Css-technique-13 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)37

Bokeh effects with CSS3 and jQuery38
This tutorial teaches you how to re-create the bokeh effect with CSS 3. With some help from jQuery, we can add some randomness in colour, size and position for the effect.

Css-technique-16 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)38

A Stationary Logo That Changes on Page Scroll with CSS 39
Here is an interesting effect that modifies the logo when the page is scrolled, using the CSS background-attachment property.

Css3-new-04 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)39

Silhouette Fade-Ins40
To achieve the effect in the image above, first we need a DIV with the silhouettes as a background image. Then we put four images in that DIV, all the exact same size, with each band member highlighted. These images are hidden by default. Then you absolutely position four regions on top of the DIV; these are the roll-over link areas. With jQuery, we apply hover events to them, fading in the appropriate image.

Css-046 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)40

Creating Triangles in CSS (the link was removed due to possible malware)
Few people realize that a browser draws borders at angles. This technique takes advantage of that. One side of the border is given the color of the arrow, and the rest are transparent. Then you give the border a large width; the ones above are 20 pixels.

Css-004 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)41

A parallax optical illusion with CSS: The Horse in Motion42
Time for some fun with CSS and optical illusions.

Css-203 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)42

Pure CSS Line Graph43
The idea here is not only to offer data visualization to people who aren’t comfortable using scripting languages, but to demonstrate the power of CSS and offer a different way of using CSS. If you are not a fan of line graphs and data visualization, you may still benefit from this article. Think of it as a CSS experiment, and learn a thing or two about CSS Sprites and positioning.

Css-037 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)43

Zooming with jQuery and CSS44
This post is about text zooming with jQuery and CSS. This is a basic-level tutorial about changing a style using a jQuery script. A simple way to zoom website content.

Css-146 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)44

Create Resizing Thumbnails Using Overflow Property45
This tutorial teaches you how to control thumbnail sizes. Sometimes we don’t have enough space to fit large thumbnails, and yet we would rather avoid small indecipherable images. Using this trick, we can limit the default dimensions of thumbnails and show them at full size when the user mouses over them.

Css-150 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)45

Cross-browser drop shadows using pure CSS46
Most methods of adding drop-shadows to content blocks require additional HTML mark-up and one or more PNG images. But by combining the Glow and Shadow filters, something that fairly closely resembles the rendered CSS3 shadow can be achieved.

Css-151 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)46

Date Badges and Comment Bubbles for Your Blog47
One of the things you have to deal with when your blog grows is having to cram more info into less space to show everything you want to show. One thing you can do is add an icon for the date and then a bubble over it with the number of comments for that post.

Css-technique-11 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)47

CSS Tables And Web Forms

UX trick: display form data as tabular data48
This is a little trick to enhance the user experience of forms. It displays editable form data as readable tabular data.

Css-technique-04 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)48

Tables: Not As Evil As You Think49
Tables are evil, right? Yes and no. For tabular data, they’re not, of course. That’s what tables are for in the first place. CSS can do an excellent job of styling a properly formatted table, and the table structure provides good scaffolding for JavaScript calls. But what is addressed here is using tables for non-tabular data (i.e. for the layout). Yes, that’s right: using tables for layout.

Css-075 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)49

Perfect Drop-Down Log-In Box Like Twitter Using jQuery50
This shows you how to create a Twitter-style drop-down log-in form using jQuery. It’s really easy, it saves space on the page and visitors feel comfortable with the awesome toggle form.

Css-158 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)50

Make a Select’s Options Printable51
When printing a Web page with select elements on it, the select drop-down prints just as it looks on the Web. This of course is practically useless on the printed page. One option for handling this is to follow every select HTML element with an unordered list that duplicates the content. Hide the unordered list in your main CSS file and reveal it with your print style sheet. This is a reasonable approach, except that it’s a big ol’ pain in the butt to deal with all the time. Let’s rely on jQuery to do the heavy lifting instead.

Css-018 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)51

Twitter-Like Log-In With jQuery and CSS52
This post explains how to get the Twitter-like hide and show effect for logging in using jQuery and CSS.” Very simple: just five lines of JavaScript for the hide() and show() events and a little CSS.

Css-145 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)52

Clean and Pure CSS Form Design53
This tutorial illustrates how to design a pure CSS form without using HTML tables.

Css-105 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)53

CSSG Collection: Free Comment Styles54
This is the second CSSG collection from CSS Globe.

Css-034 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)54

Have a Field Day with HTML5 Forms55
Here is a look at how to style a beautiful HTML5 form using some advanced CSS and the latest CSS3 techniques. You will definitely want to re-style your forms after having read this article.

Css-011 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)55

Editable/Printable Invoice56
Create editable and printable invoices using CSS and some JavaScript. This is version 2 from Vinh Pham.

Css-047 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)56

How to Mask Passwords Like the iPhone57
Many smartphones, including the iPhone, show the last character that you typed in a password field with a delay of a second or two. You can see that last character but not the entire password. But browsers don’t do what these mobile devices do. Here is a solution, with some fancy JavaScript and behind-the-scenes trickery.

Css-074 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)57

Make Web Forms Suck Less With Labels58
We’ve been filling out Web forms for years, and we all gripe that they could be better. Even with generous padding, the fields are too small. But hardly anyone has improved the most under-rated interaction of them all: checkboxes and radio buttons.

Css-technique-20 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)58

FancyForm: JavaScript checkbox replacement59
FancyForm is a powerful and flexible checkbox-replacement script that changes the appearance and function of HTML form elements. It is accessible and easy to use, and it degrades gracefully on older non-supported browsers.

Css-103 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)59

jQuery checkbox v.1.3.0 Beta 160
A lightweight custom-styled checkbox implementation for jQuery 1.2.x and 1.3.x.

Css-104 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)60

Disabled labels and the Trilemma plug-in61
The form above on the left makes use of the disabled attribute, but the default browser settings for disabled inputs don’t contrast as much as one would like. To better distinguish at a glance between which inputs are disabled and enabled, the labels of disabled inputs in the form on the right are styled with a faint gray color.

Css-127 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)61

Fluid Search Box62
Creating a fluid search box when you have only a single element next to it is trivial. What you should do is wrap the input in an element and use padding to create space for the fixed element; then position the fixed element absolutely (or relatively) in the space created by the padding.

Last Click

Browser Pong63
A whole new pong game using three browser windows for the ball and racquets. Clever!

Css-180 in 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)63

Related posts

You may want to look at similar CSS-related posts that we published last months:

(kk) (jb) (vf) (al)

Links

  1. http://www.smashingmagazine.com/2010/01/12/45-powerful-css-javascript-techniques/
  2. http://www.smashingmagazine.com/2010/02/01/50-brilliant-css3-javascript-coding-techniques/
  3. http://www.smashingmagazine.com/2009/11/23/6-useful-coding-solutions-for-designers-and-developers/
  4. http://www.sohtanaka.com/web-design/facebook-style-footer-admin-panel-part-1/
  5. http://www.sohtanaka.com/web-design/facebook-style-footer-admin-panel-part-2/
  6. http://www.jankoatwarpspeed.com/post/2009/07/07/Adaptable-view.aspx
  7. http://designm.ag/tutorials/jquery-display-switch/
  8. http://buildinternet.com/2009/07/quick-tip-resizing-images-based-on-browser-window-size/
  9. http://css-tricks.com/one-page-resume-site/
  10. http://ajaxian.com/archives/pegs-automate-display-fixed
  11. http://www.tutwow.com/tips/quick-tip-css-100-height/
  12. http://www.webdesignerwall.com/demo/css3-dropdown-menu//
  13. http://www.webdesignerwall.com/demo/css3-dropdown-menu/
  14. http://www.fivefingercoding.com/xhtml-and-css/scrolling-transparent-background-effect
  15. http://unstoppablerobotninja.com/entry/fluid-images/
  16. http://css-tricks.com/scrollfollow-sidebar/
  17. http://blog.themeforest.net/tutorials/vertical-centering-with-css/
  18. http://www.jankoatwarpspeed.com/post/2009/11/08/YouTube-adaptable-view-css-jquery.aspx
  19. http://css-tricks.com/how-to-create-a-horizontally-scrolling-site/
  20. http://buildinternet.com/2009/10/purely-css-faking-minimum-margins/
  21. http://line25.com/articles/create-sidebars-of-equal-height-with-faux-columns
  22. http://www.filamentgroup.com/lab/setting_equal_heights_with_jquery/
  23. http://blog.sugarenia.com/archives/web-design/quick-tip-centered-fake-floats
  24. http://www.webresourcesdepot.com/6-flexible-jquery-plugins-to-control-webpage-layouts-easily/
  25. http://buildinternet.com/2009/07/four-methods-to-create-equal-height-columns/
  26. http://www.webdesignerwall.com/tutorials/how-to-css-large-background/
  27. http://five.gregorywood.co.uk/index.php?/blog/article/a-nice-little-css-positioning-technique
  28. http://css-tricks.com/perfect-full-page-background-image/
  29. http://www.sohtanaka.com/web-design/smart-columns-w-css-jquery/
  30. http://tutorialzine.com/2009/11/beautiful-apple-gallery-slideshow/
  31. http://www.romancortes.com/blog/pure-css-coke-can/
  32. http://www.sohtanaka.com/web-design/greyscale-hover-effect-w-css-jquery/
  33. http://labs.dragoninteractive.com/rainbows.php
  34. http://cssglobe.com/post/6089/3-easy-and-fast-css-techniques-for-faux-image
  35. http://css-tricks.com/image-rollover-borders-that-do-not-change-layout/
  36. http://www.christinafowler.com/tutorial/horizontal-stripes
  37. http://css-tricks.com/css-image-replacement/
  38. http://www.marcofolio.net/webdesign/pure_css3_bokeh_effect_with_some_jquery_help.html
  39. http://www.impressivewebs.com/stationary-logo-changes-page-scroll-css/
  40. http://css-tricks.com/silhouette-fadeins/
  41. http://www.dinnermint.org/css/creating-triangles-in-css/
  42. http://www.marcofolio.net/css/a_parallax_illusion_with_css_the_horse_in_motion.html
  43. http://cssglobe.com/post/4175/pure-css-line-graph
  44. http://www.9lessons.info/2009/10/zooming-with-jquery-and-css.html
  45. http://cssglobe.com/post/1305/create-resizing-thumbnails-using-overflow-property
  46. http://nick-dunn.co.uk/article/cross-browser-drop-shadows-using-pure-css/
  47. http://css-tricks.com/date-badges-and-comment-bubbles-for-your-blog/
  48. http://cssglobe.com/post/6984/ux-trick-display-form-data-as-tabular-data
  49. http://www.zurb.com/article/206/tables-not-as-evil-as-you-think
  50. http://aext.net/2009/08/perfect-sign-in-dropdown-box-likes-twitter-with-jquery/
  51. http://css-tricks.com/making-selects-printable/
  52. http://www.9lessons.info/2009/12/twitter-like-login-with-jquery-and-css.html
  53. http://woork.blogspot.com/2008/06/clean-and-pure-css-form-design.html
  54. http://cssglobe.com/post/6295/cssg-collection-free-comment-styles
  55. http://24ways.org/2009/have-a-field-day-with-html5-forms
  56. http://css-tricks.com/editable-invoice-v2/
  57. http://www.zurb.com/article/279/how-to-mask-passwords-like-the-iphone
  58. http://www.zurb.com/article/195/make-web-forms-suck-less-with-labels
  59. http://lipidity.com/fancy-form/
  60. http://widowmaker.kiev.ua/checkbox/
  61. http://www.askthecssguy.com/2009/08/disabled_labels_and_the_trilem.html
  62. http://friedcellcollective.net/outbreak/2009/10/04/fluid-searchbox/
  63. http://stewdio.org/pong/

About admin

My Developer Forum is a non-profit, open source website dedicated to empowering young, eager designers and developers to take the web to a higher level of complexity, and elegance.
This entry was posted in CSS & HTML, inspiration, jQuery, Kitchen Sink. Bookmark the permalink.

2 Responses to 50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms)

  1. Bree Saxby says:

    Quite interesting posts. Hopefully this ecig liquid article could be of assistance this holiday season? Electronic Cigarette E-Liquid

  2. I’ll gear this review to 2 types of people: current Zune owners who are considering an upgrade, and people trying to decide between a Zune and an iPod. (There are other players worth considering out there, like the Sony Walkman X, but I hope this gives you enough info to make an informed decision of the Zune vs players other than the iPod line as well.)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>