Sacramento, CA

Rain 56° | 38°

Seattle, WA

Rain/Wind 54° | 38°

Buk Life

Posts Tagged ‘CSS’

13 June 2008

Styling List Items Seperately

I was wrapping up on a project, and the time came where the color on the lists (1, 2, 3) needed to be different colors than the actual <li> inside needed to be. The only solution is to wrap any content inside the <li> with some sort of tag to target the text to change the color. Although that has no problem at all, what if this needs to be site wide? It will be very cumbersome to remember, let alone do it to every list you create.

I decided to use JavaScript to search for every <ol> and for every <li> inside of it, then it goes ahead and wraps it in the selector that changes it back to default color. In this case its a <span>.

This is what it does, this will be the before HTML:

<ol>
   <li>Item text goes here</li>
   <li>Item text goes here</li>
   <li>Item text goes here</li>
   <li>Item text goes here</li>
</ol>

And, after the JavaScript does its thing:

<ol>
   <li><span>Item text goes here</span></li>
   <li><span>Item text goes here</span></li>
   <li><span>Item text goes here</span></li>
   <li><span>Item text goes here</span></li>
</ol>

Here is the JavaScript:

window.onload = function () {
   var li = document.getElementsByTagName('ol');
   for(i=0;i<li.length;i++) {
      if(li[i].childNodes[1].nodeName == 'LI') {
         var li_count = li[i].childNodes.length;
         for(b=0;b<li_count;b++) {
            li[i].childNodes[b].innerHTML = '<span>'+li[i].childNodes[b].innerHTML+'</span>';
         }
      }
   }
};

Here is the CSS:

.container ol {
	padding: 8px 10px 8px 25px;
	list-style-type: decimal;
	color: #c19203;
	font-weight: bold;
	}
	.container li {
		padding: 4px 0;
		}
	.container ol span {
		font-weight: normal;
		color: #333;
		}
1 Garrett Bjerkhoel,Developer

June 13th, 2008 at 08:11 PM
Posted By: Garrett Bjerkhoel in Development, General

5 April 2008

Save a Dev!

I did say that I wasn’t going to bother with IE6 fixes on my new site. In fact, I was planning on insulting IE6 users with a special graphic overlay. I remembered however that this would include people like

a) 50% of our clients (guessing)
b) 66% of my family (my brother introduced me to firefox)
c) 30% of everybody (according to current stats)

So, that’s a lot. So, I spent the whole day (literally) fixing the site for 6 (argh) + 7 (which was admittedly easy). Anyway, for the IE6 users, I’m using a little script from this site:

http://savethedevelopers.com/

It’s cool, it animates in a pretty image at the top of the page saying how you should upgrade and provides links to current/modern browsers. So, while not an affront to each users’ browsing sensibilities, it does provide a nice recommendation that is rather obvious.

Tags: , ,
User 'ben' not found. Maybe their WP key is set wrong.
3 ,

April 5th, 2008 at 07:52 PM
Posted By: Ben Borowski in Development

2 January 2008

IE8 Passed ACID2

I didn’t have time to pass this around over the holiday break, but the IE team announced a few weeks ago that they got IE8 to pass the ACID2 test!

[UPDATE] Garrett pointed out the IE team interview video linked page on the page. I thought it might be nice to link directly to it for you non-reader types.

Tags: ,
1 Mark Eagleton,Developer

January 2nd, 2008 at 09:07 AM
Posted By: Mark Eagleton in Development, General

14 December 2007

H

H

Tags: ,
1 Mark Eagleton,Developer

December 14th, 2007 at 09:08 AM
Posted By: Mark Eagleton in Design, Development, General