views:

131

answers:

1

Why doesn't following code work correctly in FireFox 3.6? I have tested in IE7, IE8, and Chrome with out any issues.

Issue: The first block hover link (the table's 3rd row) doesn't apply the same style/effect as the following below it.

Notes: I am trying to create my own table framework. This project is something I am doing to learn more about CSS. Before I started, I thought I knew a lot about CSS. However, to my surprise I was wrong. Who knew? Moving on... As side note, I do not want to take the time to support IE6. So, if you see a problem related IE6, please don't waste your time telling. One another side note, the following style script and HTML listed when this question is strip-down/bare-bone of the complete CSS/HTML. It should be enough to assist me.

CSS:

/* Main Properties */
.ojtable{display:block;clear:both; margin-left:auto;margin-right:auto;
    margin-top:0px; width:650px;}

.ojtable-row, .ojtable-head
    {display:block;clear:both;position:relative;
    margin-left:0px;margin-right:0px;padding:0px;}

.col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9,
.col-10, .col-11, .col-12, .col-13, .col-1-b1, .col-2-b1, .col-3-b1,
.col-4-b1, .col-5-b1, .col-6-b1, .col-7-b1, .col-8-b1, .col-9-b1, .col-10-b1,
.col-11-b1, .col-12-b1, .col-13-b1
    {display:block;float:left;position:relative;
    margin-left:0px;margin-right:0px;padding:0px 2px;}

/* Border */
.border-b1{border:solid #000000; border-width:0 0 1px 0;}
.border-ltr{border:solid #000000; border-width:1px 1px 0 1px;}
/* Header */
.ojtable-row{width:100%;}
.ojtable-head{width:100%;}
/* No Border*/
.col-2{width:96px;}
/* Border: 1px */
.col-2-b1{width:95px;}
.col-7-b1{width:345px;}    

/*--- Clear Floated Elements ---*/
/* Credit: http://sonspring.com/journal/clearing-floats */
.clear {
    clear: both;
    display: block;
    overflow: hidden;
    visibility: hidden;
    width: 0;
    height: 0;
}
/* Credit: http://perishablepress.com/press/2008/02/05/
    lessons-learned-concerning-the-clearfix-css-hack/ */
.clearfix:after {
     visibility: hidden;
     display: block;
     font-size: 0;
     content: " ";
     clear: both;
     height: 0;
     }
.clearfix { display:inline-block; }
/* start commented backslash hack \*/
* html .clearfix { height: 1%; }
.clearfix { display: block; }
/* close commented backslash hack */

/*--- Hover Effect for the Tables ---*/
a {text-decoration:none;}
.ojtable a .ojtable-row{width:650px; display:block; text-decoration:none;}
* html .ojtable a .ojtable-row {width:650px;}/* Hover Fix for IE */ 
.ojtable a:hover .ojtable-row{background:#AAAAAA; cursor:pointer;}

HTML:

<div class="ojtable border-ltr clearfix">
    <div class="ojtable-row border-b1 clearfix"> 
        <div class="col-13">Newest Blogs</div>
    </div>
    <div class="ojtable-row border-b1 clearfix">
    <div class="col-7-b1 border-r1">Name</div> 
    <div class="col-4-b1 border-r1">Creater's Name</div> 
    <div class="col-2">Dated Created</div> 
    </div> 
    <a href="#"><div class="ojtable-row border-b1 clearfix">
    <div class="col-7-b1 border-r1">Why jQuery?</div> 
    <div class="col-4-b1 border-r1">Gramcracker</div> 
    <div class="col-2">Mar 11 2010</div> 
    </div></a>
    <a href="#"><div class="ojtable-row border-b1 clearfix">
    <div class="col-7-b1 border-r1">Thank You For Your Help</div> 
    <div class="col-4-b1 border-r1">O'Hater</div> 
    <div class="col-2">Nov 2 2009</div> 
    </div></a>
    <a href="#"><div class="ojtable-row border-b1 clearfix">
    <div class="col-7-b1 border-r1">Click Me! Hahaha!</div> 
    <div class="col-4-b1 border-r1">Brian Ojeda</div> 
    <div class="col-2">Nov 29 2008</div> 
    </div></a>
    <a href="#"><div class="ojtable-row border-b1 clearfix">
    <div class="col-7-b1 border-r1">Moment of Zen</div> 
    <div class="col-4-b1 border-r1">Jedi</div> 
    <div class="col-2">Mar 11 2010</div> 
    </div></a>
    <a href="#"><div class="ojtable-row border-b1 clearfix">
    <div class="col-7-b1 border-r1">I suck at CSS</div> 
    <div class="col-4-b1 border-r1">SGT OJ</div> 
    <div class="col-2">Mar 11 2010</div> 
    </div></a>
</div> <!-- End of Table -->

PS: Thank you for assistant, if you do choose to help.

+1  A: 

I had a problem like this a while ago, it's just because you're not supposed to use block-level elements within an anchor element, it can cause undesired effects that would normally not make sense. I tried everything but the ultimate solution was just to remove all the block-level elements and replace them with standards-compliant alternatives.

animuson
Any suggestions? On what I should replace?
Brian Ojeda
Never mind. Thank you, sir. I just change the the first div after the anchor to span. Tested in IE7/8, FF3.6 and Chrome... Issue resolved.
Brian Ojeda
Possibly changing the doctype to html5 might help -if you hadn't already resolved the issue- as I believe that allows nesting block-level elements within `a`.
David Thomas
@ricebowl - I had already fix the problem before you commented by changing the first div to a span tag. But, I had just recently change my DOCTYPE to html5 a few hours before even commented on this question. Because of that I went back just to test out if the what you would work too -- it does work. Little late now but definitely something I can remember for the future.
Brian Ojeda
@Brian Ojeda, yeah, I saw that you'd already fixed it, but I figured that it'd be a heads-up for next time. =)
David Thomas