Header

Thoughts & Ideas

Showing posts with label design. Show all posts
Showing posts with label design. Show all posts

Fancy Tables with some CSS3

First off, honest -- this isn't a blog about web design entirely. And I haven't forgotten about the photography aspect either. But, hey, it's early -- haven't had my first cup of coffee yet, and I'm in a giving mood, so I thought I'd share this with you.

If you're like me, tables in web pages tend to get the least amount of love, which is rather nuts, if I think about it logically. So I finally decided to give those tables some love by applying some cool CSS3 effects. If this can help you out, great! (If not, oh well. Wait until my next post.)

So, to whet your appetite, here's what the tables look like in all their CSS3 glory:



Isn't that pretty?

So, to begin with, you'll need some CSS code:

.pkFancyTable
  {
    
    -webkit-box-shadow: black 0px 0px 12px inset, #888 0px 0px 12px;
    -moz-box-shadow: black 0px 0px 12px inset, #888 0px 0px 12px;
    -o-box-shadow: black 0px 0px 12px inset, #888 0px 0px 12px;
    box-shadow: black 0px 0px 12px inset, #888 0px 0px 12px;
    background-color: #444;
    border: 4px solid white;
    border-radius: 15px;
    -moz-border-radius: 15px;
    padding: 10px;
    width: 75%;
    margin: 0 auto;
  }
  
  .pkFancyTable tr.oddrow
  {
    background-color: #555;
  }
  
  .pkFancyTable table
  {
    border-collapse: collapse;
    color: #CCC;
    width: 100%;
  }
  
  .pkFancyTable table th, .pkFancyTable table td
  {
    border: 1px dotted #888;
  }
  
  .pkFancyTable table thead
  {
    background-color: #000;
    border-bottom: 1px solid #888;
  }
  
  .pkFancyTable table tfoot
  {
    background-color: #600;
    color: #FFF;
    border-top: 1px solid white;
  }
  
  .pkFancyTable table td div
  {
    font-size:80%;
    color: #AAA;
    margin-left:15px;
    line-height: 0.95em;
  }

Next, you need to build an HTML table wrapped in a DIV container like so:

<div class="pkFancyTable"><table cellpadding="5" cellspacing="0">
<thead>
<tr><th>Heading 1</th><th>Heading 2</th><th>Heading 3</th></tr>
</thead>
<tbody>
<tr><td>Value 1 <div>
I'm a smaller, indented line of text.</div>
</td><td>Value 2</td><td>Value3</td></tr>
<tr class="oddrow"><td>Value 1</td><td>Value 2</td><td>Value3</td></tr>
<tr><td>Value 1</td><td>Value 2</td><td>Value3</td></tr>
</tbody>
<tfoot>
<tr><th>Total 1</th><th>Total 2</th><th>Total 3</th></tr>
</tfoot>
</table>
</div>


The outer DIV classed "pkFancyTable" gives the table the nice round borders and the dark background color. Then, the THEAD element will get the black background color for the heading row. The TFOOT element will get a red background color and white text, which could be used for a row of totals. In between, the TBODY has all your normal rows, and if one of those rows has the class "oddrow", it'll get shaded a slightly different color.

Also, if you put a DIV inside of a TD, it will be indented slightly and rendered with smaller text, which makes it great for giving further information about the cell without resorting to asterisks and such.

Now, for the red-headed stepchild of browsers: Internet Explorer. Yes, well, the fancy CSS3 effects are totally lost on this poor browser, but the tables still look decent. They get the nice dark background and alternating row effects, so unless someone knew there was supposed to be a nice border, they'd be none the wiser.

Now, go and have some fun with your tables! And I promise that I'll try never to leave a table naked again. ;-)

Until next time, keep writing with light.

Changing Clothes

If you haven't noticed already, there's a new look to our site! It's not 100% complete (the Blog and Smugmug portions use the old design), but a good portion of the site has been converted to the new look and feel.

(Update 6/14/2010: The Blog has been updated to the new look and feel. Yay!)

There was nothing wrong, necessarily, with the old design. I love that design. But I happen to love this design as well, and I felt it was time for a "change of clothes" for the site. The previous design has been in place for quite awhile, and I'd learned a lot since I first coded the original design. A lot about how best to present a photograph in a site, and a lot about how to better code a site in general.

So, if you haven't already checked it out, go take a peek at the new design and see what you think. Then come back and see why the design evolved the way it did. (Or not. It's up to you. Regardless, please, leave your thoughts!)