Hard to Find CSS Tips

2Darren23rd May 2009Web Development,

Over the last few weeks I’ve picked up a few excellent css tips I felt I should share.

1. Firefox scroll jump – there are a number of techniques for enforcing the scroll bar space to appear in Firefox so users don’t see a jump as they navigate from content light to content heavy pages. My preferred option is to set the document height to 101% so Firefox always thinks there’s more, therefore shows an empty scroll bar:

html { height: 101% }

2. Equal table column widths - this is particularly useful on a content managed site where you have many users adding various data tables but you want a one style fits all. To ensure colum widths are always equal just set the following declaration:

table { table-layout: fixed }

3. Style selected text – if a user selects text on your webpage to copy and paste elsewhere, do you know you can style it so it’s not the default navy background, white text?


::selection { background: red; color: white /* Safari and Opera */ }
::-moz-selection { background: red; color: white; /* Firefox */ }

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Furl
  • Reddit
  • StumbleUpon
  • Technorati

2 Comments Comments Feed

  1. Five Minute Argument (May 24, 2009, 12:29 am).

    Hi Darren – a couple of fixes need to be made for example 3:

    1. For safari/opera, “selection” should be “::selection”
    2. For firefox, missing a closing brace

    Cheers!

  2. admin (May 24, 2009, 10:04 am).

    Thanks for pointing out my typos, I should’ve have double checked my syntax!

Add a Comment