Posted on April 23rd, 2007%
Something I like to incorporate on web sites with tables is automatic background highlighting of the row that the mouse is hovering over. This is easy to do with CSS:
table.hover tr:hover
{
background-color:#ffffcc;
}
All you need to do is give your table tag the hover class, and your mouseover hover background color works!
In all browsers except IE6, of course. IE6 only supports the :hover pseudo-class on anchor () tags. (There’s lots of other things that IE doesn’t support or supports wrong, but that’s a story for another day.)
How can we get IE6 to hover our table rows? By using a little JavaScript and the Prototype library. Our solution requires two steps:
Write some code to automatically detect mouseover and mouseout events on table rows, applying and removing a CSS class to the rows as the events occur.
Add the CSS class to our CSS file.
First we’ll add a tr.hover declaration to our CSS.
table.hover tr:hover, table.hover tr.hover
{
background-color:#ffffcc;
}
Notice that I kept the table.hover parent selector; this . . .
→ Read More: An IE6-compatible solution for :hover
Posted on April 18th, 2007%
I’m a big fan of TableKit, a JavaScript library (based on Prototype) that provides client-side sorting, row striping, column resizing, and more. (Check out their demo to see more.) There’s one feature I needed on a recent project that was missing: the ability to stripe column groups (defined with the colgroup tag) with alternating background colors (as you would stripe rows of alternating colors). It was easy to add this functionality to TableKit by adding the following JavaScript code to the TableKit library.
TableKit.ColGroups = {
stripe : function(table) {
var colgroups = table.getElementsBySelector('colgroup');
colgroups.each(function(cg,i) {
TableKit.ColGroups.addStripeClass(table,cg,i);
});
},
addStripeClass : function(t,cg,i) {
t = t || cg.up('table');
var op = TableKit.option('colgroupEvenClass colgroupOddClass', t.id);
$(cg).removeClassName(op[0]).removeClassName(op[1]).addClassName(
((i+1)%2 === 0 ? op[0] : op[1]));
},
hide : function(colgroup) {
Element.setStyle(colgroup,{visibility:'collapse'});
}
};
The code above expects two new TableKit options, named colgroupEvenClass and colgroupOddClass. To add those as available options to TableKit, find the section of code below and add the two lines named colgroupEvenClass and colgroupOddClass.
…
options : {
autoLoad : true,
stripe : true,
sortable : true,
resizable : true,
editable . . .
→ Read More: Customizing TableKit to stripe column groups
Posted on March 20th, 2007%
I found yet another interesting bug in IE7, related to using Prototype‘s Insertion.After command to insert additional table rows into an existing table. Apparently, IE7 will reverse the order of the table rows being inserted. As a proof of concept, I’ve set up an ie7 table insert bug test page to prove my point.
Here’s how to duplicate this bug.
Create a new web page (we’ll call it test.htm).
Create a <table> and add a few rows.
Give one row a specific id (such as id="insertAfterThis").
Create a separate web page (call it testdata.htm) with more table rows — just the <tr>…</tr>, nothing else.
Add the following JavaScript to run after the window loads:
new Ajax.Request(‘testdata.htm’, { method:’get’, onSuccess:function(transport) { new Insertion.After(‘insertAfterThis’, transport.responseText); } });
Load the test.htm page in Firefox, and see how the rows are inserted in the order they exist in the testdata.htm file.
Load the test.htm page in IE, and see how the order of the rows is reversed.
It’s quite a frustrating bug, . . .
→ Read More: IE7 reverses table rows during Insertion.After
Posted on March 7th, 2007%
Back in late 2006, I modified Microsoft’s CSS Friendly ASP.Net 2.0 Control Adapters to be distributable as a single DLL. Since that time, the code I wrote was downloaded from this web site, and everything seemed good, at least until the server crashed. After being prodded by a few people in the ASP.Net community, I moved this little project over to CodePlex. Before doing so, I checked to make sure this was OK with Scott Guthrie, the grand poohbah of ASP.Net at Microsoft. (You’ve got to cover your basis!)
Anyway, today I read a post on the ASP.Net forums stating that Microsoft OKs community development of the CSS Friendly Control Adapters. In short, this is a good thing for the users of this product, for reasons that are explained in that thread, and it looks like I’ll be more involved with the ongoing development of these adapters in the future. It’s also nice to see your efforts . . .
→ Read More: Microsoft OKs community development of CSS Friendly Control Adapters
Posted on October 12th, 2006%
A friend of mine was trying to get a rounded corner bar at the top of some web content. He already had the rounded corner images but didn’t know the HTML and CSS markup. I sent him over the following snippet of code as an example:
<div style="width:100%;background-color:blue;height:14px;margin:0px;padding:0px;font-size:5%;">
<div style="float:left;background-image:url('left.gif');width:14px;height:14px;">
</div>
<div style="float:right;background-image:url('right.gif');width:14px;height:14px;">
</div>
</div>
To understand, note the following:
The width:100% should be set the width appropriate to your content.
The width and height (14px in the example above) should be replaced by the actual width and height of your rounded corner images.
What’s with the font-size:5%? Making the font size very small will ensure that any white space will not create a block larger than the desired height (in our case, 14px).
The following bar was made using the above . . .
→ Read More: Simple rounded corners
|
|
Recent Comments