All posts in CSS

My First Shot at Adaptive Images

One of the first problems you run into when trying to build an adaptive layout is that images, unlike blocks of text, have fixed widths. Ideally we want to use small images on small screens and full sized ones on larger screens. The browser can resize the image on the fly, but the two problems with this… [more]

A Primer on Responsive Web Design

Ben Callahan from Sparkbox shared some good links on responsive web design recently, one of them being this introduction to the subject from A List Apart. One of the things that struck me from the article was that “[mobile] browsing is expected to outpace desktop-based access within three to five years.” Another link to Smashing Magazine was a reference of… [more]

W3Schools Isn’t Official or Accurate

Divya Manian gave a presentation yesterday at WordCamp Seattle about generating proper markup when creating output from plugins, and she mentioned a site called W3Fools.com , which is basically a protest against W3Schools.com . I didn’t realize until I saw W3Fools, but W3Schools isn’t actually ran by the W3C, and it contains a lot of inaccurate information. Further, it seems like… [more]

Body Classes Instead of Conditional Stylesheets

I’m thinking I should create a, ‘Duh, why didn’t I think of that?’ category for this. Instead of using conditional stylesheets or CSS hacks to fix Internet Explorer’s obnoxious lack of support for standards, you can  conditionally set a class on the html or body tag and target that in your normal stylesheet. This is better for several reasons, including faster page load times and… [more]

Light and Clean CSS Message Box Styles

Here are a couple examples of good colors to use for clean CSS message boxes: http://www.mattvarone.com/web-design/message-box-with-css/ http://www.ajaxlines.com/ajax/stuff/article/css_message_box_collection.php

Sub-pixel letter-spacing in CSS

There’s a thread on the Sitepoint forums about the smallest amount of letter-spacing you can use . Most of the responses are useless, annoying and wrong, but #36 finally gives a good answer. Most browsers only support integer pixel values for letter-spacing. This is a problem because, when it comes to letter-spacing, there’s a big difference between 0 and 1px. Ems and other relative… [more]

Distributing Fonts Via @font-face

Instead of using images, Flash or JavaScript to replace normal text with non-standard fonts, you can now use CSS’s @font-face rule . It will tell the browser to download the fonts and render the text using them. Internet Explorer uses the EOT format and everyone else uses TrueType, so you need to declare the sources in a specific order to make it work across browsers . You can get compress… [more]

Z-Index Stacking Contexts

One important thing to keep in mind while working with z-index is that multiple stacking orders are created based on the markup hierarchy. This means that an element with a z-index of 30 can actually appear below an element with a z-index of 20, if the z-index of the original element’s parent is 10. Paolo Lombardi… [more]

CSS Selector Browser Compatbility

kimblim.dk has a chart showing browser support for various CSS selectors , including pseudo selectors. It includes CSS versions 1 through 3 and all of the major browser versions.

Content Above Anchors Disappear

It turns out there’s a serous problem with the One True Layout method of creating equal height columns . All of the content above an anchor will be shifted up , making it seem like it disappeared. There aren’t any universal or reliable fixes for this, so the Faux Columns method is probably the best choice if it’ll fit the design.

Using overflow to Clear Floated Elements

If you have an element whose children are all floated, it won’t have any height to it. I’ve always just put an extra <div style=”clear: both;”> at the bottom of the container to force it to clear, but it looks like there’s been a much better way for a few years now. Alex Walker points… [more]

Placing an Element In Front of an Object

Here’s how to have a drop-down menu appear on top of a Flash object: Add a z-index of 0 to the object’s containing div Add <param name=”wmode” value=”transparent”> inside the object tag Add wmode=”transparent” to the embed tag via Sheriar Designs

The Best Way to Define Font Sizes in CSS

Often designers will want fixed font sizes so that the text on the actual size will exactly match their mockups, but The Web is Not Print (see also Pixel Perfect Design Does Not Necessarily Equal Good Web Design ). A List Apart has a worked out a good method for sizing text consistently across browsers while maintaining the user’s ability to resize the text to fit their needs. All you need to do is define a baseline size and line height in the body… [more]

Internet Explorer Doesn’t Match PNG Color to CSS Color

All currently available versions of Internet Explorer incorrectly display colors in PNG images . To work around that, instead of setting a background color, you can use create 1×1 pixel image with the color you want, and set it as a repeating background image .

CSS Drop-Down Menus

Tomas Bagdanavicius has created a fast, themeable, cross-browser CSS-based  Drop-Down Menu Framework that only uses Javascript for IE6.

Preloading Images

UPDATE: Now that all modern browsers (that is, everything except IE8 and older) have support for multiple background images via CSS3 , that is my preferred method. It’s detailed by Jeff Starr in his post, Better Image Preloading with CSS3 . * * * * I’ve been looking for a good way to preload images for rollovers, but it seems like a lot of the common methods… [more]

Clearing a Browser’s default CSS stylesheet

Clear a browser’s default CSS stylesheet Update: After working with it for a little while I prefer using Yahoo’s Reset CSS , Base CSS and a few custom values to Meyer’s version. I think he takes it too far (almost to the point of absurdity) with things like stripping the weight from the strong tag.

Targeting properties to IE6 with Valid CSS

When I’m translating a design to markup I can usually get it to look the same in all the major browsers without too much trouble, but every once in awhile there’s a problem with IE6 that I can’t figure out, or just don’t have the time/energy to deal with the right way. In the past… [more]

 
re-abolish slavery