Not signed in (Sign In)

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

Categories

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

    •  
      CommentAuthorAvean
    • CommentTimeMay 20th 2008
     permalink
    Hi,

    I have problems with positioning a div to the right.
    Right now i have a wrapper that is positioned relative with a width of 100% and height of 100%. In the wrapper i have my div positioned right but it doesnt go right, it stays absolute no matter what. Even tried with float:right; but doesnt work.

    HTML:
    <div id="wrapper">
    <div id="rightdiv" align="right">
    </div></div>

    CSS:

    #wrapper {
    position:relative;
    width:100%;
    height:100%;
    }

    #rightdiv{
    position:absolute;
    width:370px;
    height:781px;
    background-image:url(img/rightart.jpg)
    }
    •  
      CommentAuthorhumainmtl
    • CommentTimeMay 20th 2008
     permalink
    if you're doing absolute, use:

    right: 0;
    top: 100px; /* or whatever you want */

    if you want it to float right, use position:relaive for #rightdiv
    •  
      CommentAuthorAvean
    • CommentTimeMay 20th 2008 edited
     permalink
    Awesome that worked :) Didnt know that. But how do i do it in the opposite direction ? Like left ? Thought i could do left: 0; but it turned right as well.

    Never mind, i did position:fixed; on that div and it worked :)
  1.  permalink
    Don't use align="right" — that doesn't do anything besides invalidate your page.

    If you want to actually float something, use #rightdiv { float:right; } — or float:left; if you want to, well, float it to the left.

    Floats aren't as easy as relative, absolute or fixed positioning, but it's still something well worth looking into. In addition to learning about floats the second most important thing is to know that every time you float something you have to use display:inline; for IE. Otherwise the padding (or was it the margins) will double.

    Clearing the floats is also a subject worth exploring.
    •  
      CommentAuthorAvean
    • CommentTimeMay 21st 2008
     permalink
    Ok but i cant seem to get it to work. I have one div that i have to the right now which i did with the left:0; and the only way i can get the second div to the left is by specifying in pixels left:500px; but i need it to stay all the way to the left, even if the user resizes the window. Tried with floating also but the div stays and overlaps with the first div to the right.
    •  
      CommentAuthorTetsuo
    • CommentTimeMay 21st 2008
     permalink
    I think this is what you're after:

    CSS:
    #wrapper {
    position:relative;
    width:100%;
    height:100%;
    }
    #leftdiv{
    position:absolute;
    top:0;
    left:0;
    width:370px;
    height:781px;
    background:#eee;
    }
    #rightdiv{
    position:absolute;
    top:0;
    right:0;
    width:370px;
    height:781px;
    background:#ddd;
    }

    HTML:
    <div id="wrapper">
    <div id="leftdiv"></div>
    <div id="rightdiv"></div>
    </div>

    But kari.patila is right about using floats instead of positioning elements like this. Try removing the 3 positioning properties altogether on both elements and apply floats instead (float:left, float:right etc.) and see what happens.
    •  
      CommentAuthorAvean
    • CommentTimeMay 21st 2008 edited
     permalink
    Thank you :) I see what i did wrong. I didnt close the divs properly, i closed the divs i had after tons of content which is wrong. Now it works on all browsers :) cool
    Except Opera which doesnt handle the styling of the forms evidently. I have labeled my form and control it in my CSS with label { display:block:width:100px;float:left;} guess Opera cant do that :(

    Never mind, Opera couldnt handle <p> so i had to use < br/> in case anyone needs the solution ;)
Add your comments
    Username Password
  • Format comments as (Help)