tags:

views:

126

answers:

4

I've added some expand/collapse functionality to a table with jQuery and I'm now trying to do some fine tuning on the button positioning with CSS, - yet I can't seem to act on the img element.

Here's an extract from my code:

<body>
 <h1>Outstanding repairs assigned to me</h1>
  <table class="sortable paginated collapsible">
   <thead>
   </thead>
   <tbody id="emergency">
    <tr>
     <th colspan="7">
      Emergency
       <img class="alignment clickable" src="../repair_system/media/minus.png" alt="Collapse this section"/>
     </th>

And the first entry in my CSS file is:

.alignment {
    border:7px solid black;
 }

The page is picking up the CSS class 'clickable' - but it's ignoring 'alignment' for some reason. Firebug doesn't even reference the CSS class in the CSS styles pane.

Can anybody think of something obvious that I've missed here?

+3  A: 

The snippet you posted (modified slightly to include the CSS as well, and to point to a different image) works for me in a few different browsers. So, it looks like the problem must be in something else in your code. You might want to try reducing the problem down to a small snippet that demonstrates the problem, and post that; in the process of reducing it down, you may even discover the problem yourself.

Brian Campbell
Fixed - the error was being caused by a stray "b" character on line 1 of the css file - no idea how it got there! This approach led me to the solution - thanks.
chriswattsuk
+1  A: 

Have you tried adding the !important decleration to the CSS to see if it's simply being overridden by other CSS?

.alignment {
    border:7px solid black !important;
 }
Jamie Dixon
Just tried that, but no joy...
chriswattsuk
How are you including the CSS in the page? Are you sure it's definately there?
Jamie Dixon
+1  A: 

what browser are you using? Quirks mode or not? (http://en.wikipedia.org/wiki/Quirks%5Fmode).

The snippet works for me too (inlined the css).

Inlined css: just put it inside of

<style></style>

tags. Best done within the header.

Ralf
I'm using FF3 - have tried in IE8 too but same issue..
chriswattsuk
FF3 and IE8 shouldn't be a problem as long as you are not in quirks mode.
Ralf
+1  A: 

As far as I remember, IE displayed in older version images which are linked always with a border. You had to remove this border by setting the style to no border.

Maybe jQuery tries to avoid this problem by magically setting the image border to 0px. try to override this by setting the style directly in the img tag:

<img style="border:7px solid black" ... > ...

this should override all other styles.

Yes, I know. Setting the style this way isn't best practice, but maybe it helps debugging. If it works, you know that the style is set somewhere else and overrides your own definition.

BTW: using FF plugins like "web developer" might help too. There are some of those tools whihc manage to show you the source of the style definition for specific elements.

Ralf