Css Discussion - Positioning

Discussion in 'GR Classic Archive' started by Wonderboy, Oct 6, 2006.

  1. Wonderboy

    Wonderboy Well-Known Member

    Posts:
    1,347
    Likes Received:
    0
    Joined:
    May 19, 2005
    I was wondering if anyone out there could help me with a little Css.

    The main thing i am having problems with, well, maybe not problems but would like to learn more about, is positioning.

    When making my css layouts such as:

    http://www.wonderboy.mythicx.com/wip2/ and also
    http://www.wonderboy.mythicx.com/business

    I postion everything using floats, mainly float:left, and then, if needed i will add a margin.

    Now my question is, is this the best way to do it ? and is the the RIGHT way.

    I have read and seen people positioning by using "postion:relative;" and "postion:absolute;" and then adding something like:

    top:20px;
    left:40px;

    Now to me this seems to have the same function as adding a margin, but i'm not really sure.

    So basically what i am asking is, is there a right way to position is css?

    Also just a quick question to throw in - Do you think it's better to give Div's a certain width or height. Or do you think it is best to give them set widths and heights. Really, i think it depends on the template.

    I also think there should be a forum set up for this type of discussion.

    Thanks in advance people.
     
  2. KurodaKun

    KurodaKun Well-Known Member

    Posts:
    362
    Likes Received:
    0
    Joined:
    Mar 2, 2006
    I don't realli like them. They are quite flat and too simple
     
  3. Wonderboy

    Wonderboy Well-Known Member

    Posts:
    1,347
    Likes Received:
    0
    Joined:
    May 19, 2005
    I'm not asking you to rate them...
     
  4. aplix

    aplix Well-Known Member

    Posts:
    215
    Likes Received:
    0
    Joined:
    Dec 31, 2004
    this isn't meant to sound as if im attacking u or defending the other guy but this is the web templates show off area, u might hav been better posting it there....good luck with this...i use % if that helps at all lol :(
     
  5. Wonderboy

    Wonderboy Well-Known Member

    Posts:
    1,347
    Likes Received:
    0
    Joined:
    May 19, 2005
    There is no real place for this. My questions are Web related and out of all the forums here i thought this one was the most suitable place for me to poast it.

    My question about position is still on my mind. So if anyone can be of some help and answer my question that would be great.

    The websites i posted are just there to show examples of my work, using the way i position.

    Thanks in advance
     
  6. Xero3009

    Xero3009 Well-Known Member

    Age:
    34
    Posts:
    200
    Likes Received:
    0
    Joined:
    Apr 3, 2005
    Location:
    South Carolina
    positions are meant for absolute positioning, thus the name

    floats are actually meant to float image or something in a body of text, and the text wrap the image, it's only used for blocks because it's quick and it works. 1 flaw: no left columned sidebars without float the content to the right and set a width, it's pretty tough

    and there is no real right way to do it, you do what you want, but certain things are for certain circumstances
     
  7. Dumb Genius

    Dumb Genius Member

    Posts:
    9
    Likes Received:
    0
    Joined:
    Mar 12, 2005
    Well "postion:relative;" and "postion:absolute;" are eventually like margins but like the name indicates, it's to position an element in function of its parent element for relative and from the top left corner for absolute. Then you can add a margin.
    Each property has its own function even though you can do the same thing with some of them. The best example is tables which are used for coding templates and which are not meant to do that at all.
     
  8. Xero3009

    Xero3009 Well-Known Member

    Age:
    34
    Posts:
    200
    Likes Received:
    0
    Joined:
    Apr 3, 2005
    Location:
    South Carolina
    ^^exactly :)
     
  9. Wonderboy

    Wonderboy Well-Known Member

    Posts:
    1,347
    Likes Received:
    0
    Joined:
    May 19, 2005
    Thanks for the replys guys. So i now see that there is no "right" way to do it. It's really down to personal preference.

    Is there a way it should be done though? I know that both way work.

    Professional web desingers. Do you think they would use whatever they felt comfortable using? Or would they use a certain one.

    Thanks
     
  10. Xero3009

    Xero3009 Well-Known Member

    Age:
    34
    Posts:
    200
    Likes Received:
    0
    Joined:
    Apr 3, 2005
    Location:
    South Carolina
    They'd probably use positioning since that's what it's meant for, and floats are meant to make text wrap images in text areas
     
  11. Wonderboy

    Wonderboy Well-Known Member

    Posts:
    1,347
    Likes Received:
    0
    Joined:
    May 19, 2005
    Looks like ill need to start learning positioning :) Not exactly sure what the difference beteen absolute and relative positioning are.
     
  12. MrSteve

    MrSteve Well-Known Member

    Posts:
    523
    Likes Received:
    0
    Joined:
    Nov 27, 2005
    I used this for centering..
    Code:
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: /half-of-width/px;
    margin-top: /half-of-height/px;
    Except reverse the sign on the margins. So if your width is 800px, put "margin-left: -400px;"
     
  13. Phili G

    Phili G Well-Known Member

    Age:
    35
    Posts:
    1,498
    Likes Received:
    0
    Joined:
    Oct 5, 2005
    Location:
    England!
    you use
    marin:auto
    padding:0

    to center?
     
  14. Xero3009

    Xero3009 Well-Known Member

    Age:
    34
    Posts:
    200
    Likes Received:
    0
    Joined:
    Apr 3, 2005
    Location:
    South Carolina
    you just need margiin-left: auto; and margin-right: auto; to center blocks :P, no need to position things just for the sake of centered content ;)
     
  15. Wonderboy

    Wonderboy Well-Known Member

    Posts:
    1,347
    Likes Received:
    0
    Joined:
    May 19, 2005
    Yep, margin-left:auto; margin-right:auto; will center.
     

Share This Page