tags:

views:

577

answers:

3

Hi All,

I am making cosmetic changes to a website but I am only able to change the CSS not the aspx. I want to move an image that is inside a cell in a table set into the page by about 100/100px back to 0/0px.

The tag has got a unique id I can get at it with however the table's id is not unique and setting a background image on the table from css affects other parts of the site. I've also tried setting a background image on the body however this page is a frameset where each frame references the same stylesheet. The result is that I get a background image in each frame.

A greatly simplified version of the html is as so:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
    <head>
        <title>move image</title>
        <style type="text/css">
            #imgLogo {/*how can I move this to 0,0?*/}
        </style>
    </head>
    <body>
        <table style="margin-left:100px; margin-top:100px;">
            <tr>
                <td>
                    <img id="imgLogo" src="http://www.google.com/intl/en_ALL/images/logo.gif" alt="google" />
                </td>
            </tr>
        </table>
    </body>
</html>

Cheers,

Chris

EDIT

Thanks to everyone who said to use position absolute. This certainly fixed the example html but not the real problem. The reason was that one of the parent elements already had a position absolute set but no co-ordinates. Setting this elements left and top position did the trick.

+1  A: 

use css positioning:

something like that:

imgLogo {

position:absolute; top:100px; left:100px; }

Aviv

Ok, this is strange. This seems to do the job perfectly on the example I gave but this is the first thing I tried and it does not work for the real example. You can definitely have a point for answering the question but I'm afraid it was a bad question.
Chris Simpson
+1  A: 

Set the tables ccs to position:relative and your image to position:absolute and give it top:0px and left:0px;

Rigobert Song
As I said above (beaten by 4 seconds - and you actually got the numbers right) this works for the given html but not the real html. This tells me that something else is stopping this image moving. thanks.
Chris Simpson
is there another css file being referenced on the page?
Rigobert Song
No, definitely not. I've checked and double-checked this.I've just had a look at the problem again and the table that the image is in is nested inside another table. I'm going to see if that makes a difference to my example. If so I'll alter the question to show the new example html.
Chris Simpson
As I mentioned in the edit, the problem is now solved. A parent element was already position absolute but with no specified co-ordinates. Setting this to 0,0 did the trick.
Chris Simpson
A: 

Absolute positioning is the key:

#imgLogo {
    position: absolute;
    top: 0;    // This is the default value, but whatever
    left: 0;   // ^
}
Andrew Noyes