SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict lundberg's Avatar
    Join Date
    Mar 2003
    Location
    Sweden
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Positioning images with css?

    Hello,

    Can't I position a image with css? If I don't remember wrong you could do something like:
    Code:
    something {
        position: absolute(or relative); 
        left: 10px; 
        top:10px;
    {
    or atleast do:

    Code:
    <img src="path" alt="..." style="position:absolute; left:10px; top:10px;">
    or am I wrong in both cases?

    Martin Lundberg
    Sweden

  2. #2
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    Both will work, it all depends on what you are trying to achieve as the image position will be absolute (or relative) to other content on your page, depending on whether it is contained in any other absolute or relatively positioned elements.

    Paul

  3. #3
    SitePoint Wizard Ian Glass's Avatar
    Join Date
    Oct 2001
    Location
    Beyond yonder
    Posts
    2,384
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or, if you're using NS4? I think it has trouble with positioning anything that's not a div or span (but I may be wrong on that count). Seems I remember that frustrating me once upon a time.
    ...position will be absolute (or relative) to other content on your page...
    Little clarification. Relative positioning is relative* to where the positioned thing is in the normal flow (so it's basically relative to itself). Something that's absolutely positioned is taken out of the normal flow and positioned relative* to its closest positioned (either relatively, absolutely or fixed) container, like Paul said. Fixed positioning is relative* only to the viewpoint (i.e. the browser window); it's also taken out of the normal flow.

    OK, so maybe that clarification didn't clear much of anything up, but hey it's CSS, what'd you expect! :-p

    ~~Ian

    * Bad choice of words I know, but I couldn't think of anything else that'd work.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •