Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    •  
      CommentAuthorAvean
    • CommentTimeApr 27th 2010 edited
     permalink
    Hi,

    I normally use position: relative for every div i create. You need to do that to be able to use left: 100px and top 300px: and so on to position elements right? You have absolute also but that doesnt consider everything else, cause its absolute positioning.

    So i always use position: relative on everything that i wanna position. Is that correct?
  1.  permalink
    All DIVS positioned by default relatively. There are some situations when you might need to use absolute position for element of a page but in most cases
    positining div relatively will serve you design needs. Beside absolutly position divs not always behave they way they should.


    Cheers, DS
    • CommentAuthorbigirl
    • CommentTimeApr 29th 2010
     permalink
    dmityseliv is wrong!
    All divs default position is actually static.
    Since usually websites designed for a minimal 1024 x 768 resolution, I actually define position: relative on my main container,
    like the first div on the page that wraps all content and have fixed width and auto margins.
    Then everything else is positioned relative to it and not to page

    View my demo
  2.  permalink
    I meant I reset all divs by default be relative.

    DS
    • CommentAuthorbigirl
    • CommentTimeMay 2nd 2010
     permalink
    Why?
  3.  permalink
    Relative means, 'relative to where the element WAS (because you'll be moving it) in the normal document flow.' However, as mentioned, it's also the means by which you say a div is to the be index point (top left for 0,0) for any child within that div.

    I use absolute and relative about the same. If I know the content is set and not dynamic, then I use absolute which eliminates more css bugs than dealing with floats and if there are small changes, no worries, I just update coordinates.

    But, lately I've been using JQuery and its positioning utility because it doesn't require any element to be 'relative' nor 'absolute'... and you can plan for dynamic content as if you were using floats but have much more precise measurements. One wrapper contains, say, four columns of info and in the the document flow, more content is added before that wrapper, then the wrapper moves down to allow for the new content but since JQuery's position is based on that wrapper and the child elements are based off of the wrapper that moved, it all moves.

    Check it out. Search for "JQuery" "position utility" NOTE: it's not the same as using the position method as in $(#someDiv).position(top:20,left:40); that's essentially the same kind of thing as using sheer CSS absolute positioning.

    An example of what you do:
    $("#myContent").position({
    my: "left top", // Horizontal then vertical, this line (yes, it's 'my') defines what is being moved and what point to reference..in this case the top left of the div
    at: "right top", // Horizontal then vertical, where are you aligning the div to? In this case to the right top of the div below
    of: $("#referenceDiv"), // Element to position against...sort of what would be position:relative.
    offset: "20 0" // Pixel values for offset, Horizontal then vertical, negative values OK
    });
Add your comments
    Username Password
  • Format comments as (Help)