50 Useful Coding Techniques (CSS Layouts, Visual Effects and Forms) - Smashing Magazine Advertisement 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 Panel4Learn how to re-create the Facebook footer admin panel with CSS and jQuery. Adaptable View: How Do They Do It?
All About Floats What is "Float"? Float is a CSS positioning property. To understand its purpose and origin, we can look to print design. In a print layout, images may be set into the page such that text wraps around them as needed. In page layout programs, the boxes that hold the text can be told to honor the text wrap, or to ignore it. In web design, page elements with the CSS float property applied to them are just like the images in the print layout where the text flows around them. Setting the float on an element with CSS happens like this: There are four valid values for the float property. What are floats used for? Aside from the simple example of wrapping text around images, floats can be used to create entire web layouts. Floats are also helpful for layout in smaller instances. This same layout could be accomplished using relative positioning on container and absolute positioning on the avatar as well. Clearing the Float Float's sister property is clear. Clear has four valid values as well. Video
Applying border & opacity to images onMouseover in CSS Applying border & opacity to images onMouseover in CSS In this tutorial, I'll show you how to use CSS alone to reproduce two popular image effects that have traditionally been done using scripting. The advantage of looking to CSS instead is obvious- much more lightweight and easier to implement. The two effects in question are: For cross browser compatibility (IE5+, FF1+), the image needs to be hyperlinked in order for the CSS to work, as IE (as of IE6) only supports the ":hover" pseudo class on A elements. Applying border onMouseover to images First up, the CSS technique for applying a border to image links onMouseover: By using the CSS pseudo class ":hover", we apply the enclosed CSS definitions to only when the mouse moves over any image with class="borderit". Applying opacity onMouseover to images Moving on, here's the CSS code for manipulating an image's opacity onMouseover: Note the two different properties used to specify opacity in CSS.
CSS Media Queries We've covered using CSS media queries to assign different stylesheets depending on browser window size. In that example, we changed the layout of the entire page based on the space available. It isn't required that we make such drastic changes with this technique though, so in this tutorial we'll go over a design tweak with a smaller scope. We'll also cover the syntax for using media queries within a single stylesheet and more examples of that. The CSS media query syntax for calling an external stylesheet is like this: You may be familiar with the media attribute, normally being "screen" or "print" or even a comma separated list, like "screen, projection". Likewise, you can use more advanced CSS media queries like: You may use as many media queries as you would like in a CSS file. Example Let's say we have a fluid width design where the sidebar is 35% of the width of the page. In our example sidebar, we are going have a list of names of the Super Team which function as email links. Types
meyerweb.com When can I use... Tutorials: CSS Link Styles Want to know how to create CSS link styles (pseudoclasses)? It's easy! Just follow along and you'll be a master in no time. link style syntax Default link styles look like this in a style sheet: A Style, in CSS jargon, is called a Rule. The first part of the Rule (a:link)is called the Selector. The curly bracket pair contains the Declaration, which is comprised of a Property (color) and a Value (#333333). The Selector a:link can roughly be translated to mean: Mr. why don't we set the font family? Notice that our 4 link styles (link, visited, hover, and active) declare neither font-family nor font-size. So, if the link is in a paragraph, it will inherit its font and size from that paragraph. what is a link... really. Links are links because they are wrapped inside anchor <a> tags: This sentence, containing this link to thislink.htm looks like this in the source code: Notice that the actual hyperlinked words —this link— are contained between an opening <a> tag and a closing </a> tag. a:link
How to Centre a DIV Block Using CSS Standard Trick to Centering a Block of Text/Images Using Cascading Style Sheets by Christopher Heng, thesitewizard.com This article shows you how to centre (or "center" in US English) a DIV block, whether it contains text, graphics, or a mixture of both, using standards-compliant Cascading Style Sheets (CSS). Assumptions I will assume in this article that you have some basic knowledge of how to write HTML and CSS. If you don't even have a website yet, and have arrived at this article looking for tips on designing one, please start with my article on How to Start/Create Your Own Website instead. Steps to Centering a DIV Block without Centering the Text Inside Let's assume that you have a div block as follows: <div id="content"> This is a DIV block that is to be centred. At first glance, you may think that the following CSS rule will work. text-align: center ; However, the rule centres the text inside the box, rather than the block itself. Both steps are necessary. Demo Browser Support Conclusion