Is Absolute Postioning so bad? Can I expect problems?

Discussion in 'CSS' started by wd_2k6, Sep 22, 2008.

  1. #1
    Hi, I was wondering I usually use floats and so on, but I have an object (video player), which is in a set position regardles of whatever happens, therefore it's a lot easier just to position it on the page say 300px from the top and 30px from the left.

    Would this cause any problems with any browsers?

    Many thanks in advance to any opinions on abs positioning :)
     
    wd_2k6, Sep 22, 2008 IP
  2. rikun

    rikun Peon

    Messages:
    85
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't think it should cause too many, if any, problems. Just remember to z-index stuff around it so that it doesn't get covered by anything.
     
    rikun, Sep 22, 2008 IP
  3. AnonymousUser

    AnonymousUser Peon

    Messages:
    593
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Having just that should be fine, Only problems you mostly get with absolute positioning is browser compatability as you already said, If you have some other browsers installled you can check it yourself
     
    AnonymousUser, Sep 22, 2008 IP
  4. Grit.

    Grit. Well-Known Member

    Messages:
    1,424
    Likes Received:
    22
    Best Answers:
    1
    Trophy Points:
    110
    #4
    Just a noob question, but what's z-index?
     
    Grit., Sep 22, 2008 IP
  5. live-cms_com

    live-cms_com Notable Member

    Messages:
    3,128
    Likes Received:
    112
    Best Answers:
    0
    Trophy Points:
    205
    Digital Goods:
    1
    #5
    z-index is the layer on the page...if you make it z-index 500 it'll always be on top of the other things on the page.

    Floats are easy to make cross-browser compatible, absolute positioning is less so.
     
    live-cms_com, Sep 22, 2008 IP
  6. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks for the replies.

    Grit if you have two elements which overlap each other on your page, then you can use Z-Index to choose which element appears on top. So if you give one element a Z-index of 100, and another a Z-index of 5, and say they overlap due to positioning or whatever the one with a Z-index of 100 would appear over the top.

    Is the following possible with positioning?
    A DIV 30px from the top done by positoning, but 500px from the left, and re-sizes with the browser window, so takes up all remaning space apart from 500px gap on the left?
     
    wd_2k6, Sep 22, 2008 IP
    Grit. likes this.
  7. live-cms_com

    live-cms_com Notable Member

    Messages:
    3,128
    Likes Received:
    112
    Best Answers:
    0
    Trophy Points:
    205
    Digital Goods:
    1
    #7
    width: 100%;
    margin-left: 400px;

    I imagine.
     
    live-cms_com, Sep 22, 2008 IP
  8. Grit.

    Grit. Well-Known Member

    Messages:
    1,424
    Likes Received:
    22
    Best Answers:
    1
    Trophy Points:
    110
    #8
    Thanks for the help there wd 2k6 ^^
     
    Grit., Sep 22, 2008 IP
  9. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #9
    [​IMG]

    Well this is what i'm trying to achieve.
    DIV 1 is about 500px
    DIV 2 is about 50px and floated next to DIV A, you can ignore it really.
    DIV 3 I want to be 100% (of remaining space that is) and next to 2.

    However I don't want 3 to be floated, rather positoned. Because 1 can be enlarged via Javascript, and should simply overlap 3. floats will cause 3 to drop to the next line rather than it overlap.

    So how do I abs position 3 as in the diagram, taking up 100% of width but with a 550px left margin?

    Live-cms you can't set 100% width, because then the width of the DIV is 100%+550px.
     
    wd_2k6, Sep 22, 2008 IP
  10. mypsdtohtml

    mypsdtohtml Guest

    Messages:
    96
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I don't think it should cause too many problems in your CSS.
     
    mypsdtohtml, Sep 23, 2008 IP
  11. buzzmaker

    buzzmaker Peon

    Messages:
    103
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Absolute positioning is not at all Bad. Some people say Floats are bad, some say absolute positioning is bad. But the real thing is not knowing both these very well is bad and that is what creates problems. One should know how floats and absolute positioning works and what it should be used for. Then only these will prove a boon instead of creating problems.

    Half knowledge is dangerous. and using absolute positioning where it is not required create problems for sure.
     
    buzzmaker, Sep 24, 2008 IP