Cannot read property ‘style’ of undefined — Uncaught Type Error

Add your <script> to the bottom of your <body>, or add an event listener for DOMContentLoaded following this StackOverflow question. If that script executes in the <head> section of the code, document.getElementsByClassName(…) will return an empty array because the DOM is not loaded yet. You’re getting the Type Error because you’re referencing search_span[0], but search_span[0] … Read more

CSS Color Filter Overlay

A combination of CSS filters would be one method but without seeing the actual source page it’s hard to be certain. Expand snippet Alternatively, a simple greyscale filter with a transparent green overlay. Expand snippet

CSS rotation cross browser with jquery.animate()

CSS-Transforms are not possible to animate with jQuery, yet. You can do something like this: You can read more about the step-callback here: http://api.jquery.com/animate/#step http://jsfiddle.net/UB2XR/23/ And, btw: you don’t need to prefix css3 transforms with jQuery 1.7+ Update You can wrap this in a jQuery-plugin to make your life a bit easier: http://jsbin.com/ofagog/2/edit Update2 I … Read more

How to select label for=”XYZ” in CSS?

The selector would be label[for=email], so in CSS: …or in JavaScript using the DOM: …or in JavaScript using jQuery: It’s an attribute selector. Note that some browsers (versions of IE < 8, for instance) may not support attribute selectors, but more recent ones do. To support older browsers like IE6 and IE7, you’d have to use a … Read more

CSS selector for first element with class

This is one of the most well-known examples of authors misunderstanding how :first-child works. Introduced in CSS2, the :first-child pseudo-class represents the very first child of its parent. That’s it. There’s a very common misconception that it picks up whichever child element is the first to match the conditions specified by the rest of the … Read more

CSS – why doesn’t percentage height work? [duplicate]

The height of a block element defaults to the height of the block’s content. So, given something like this: #inner will grow to be tall enough to contain the paragraph and #outer will grow to be tall enough to contain #inner. When you specify the height or width as a percentage, that’s a percentage with … Read more

Why are my divs overlapping?

They are overlapping because you are floating a div, but aren’t clearing the float. Use the clearfix method to clear the float. Add a class container to your container divs and use this CSS: http://jsfiddle.net/57PQm/7/ You’ll also notice that I’ve removed your inline CSS. This makes your code easier to maintain.