eleven0 Posted October 10, 2008 Share Posted October 10, 2008 I use position:absolute; top: 120px; left:24%; It works fine, I have set my div as i wanted but when you resize your browser, div moves around too(positions itself with those values within the resized browser). Is there a way for me to stick that div at that place. I don't want it to move as you resize your browser. I chose position:absolute because it's really easy for me to put whatever i want wherever i want, but everything gets messed up when you resize your browser. Any alternative ways or ideas? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 10, 2008 Share Posted October 10, 2008 Dont absolutely or relatively position your divs. Look in to other methods such as floats. What type of layout are you trying to achive? Quote Link to comment Share on other sites More sharing options...
eleven0 Posted October 10, 2008 Author Share Posted October 10, 2008 Hmm, I have a single centered column where i put my content and I decided add a sidebar on the right side. it seemed real easy to put that sidebar using that property. Quote Link to comment Share on other sites More sharing options...
dropfaith Posted October 10, 2008 Share Posted October 10, 2008 use floats here http://css.maxdesign.com.au/floatutorial/ Quote Link to comment Share on other sites More sharing options...
eleven0 Posted October 10, 2008 Author Share Posted October 10, 2008 Thanks, I know how to use floats. That's a great site btw. Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted October 12, 2008 Share Posted October 12, 2008 Dont absolutely or relatively position your divs. Look in to other methods such as floats. What type of layout are you trying to achive? Why would you not want to relatively position your divs? As I understand it, relatively position divs is just as beneficial as floating a div. Quote Link to comment Share on other sites More sharing options...
haku Posted October 13, 2008 Share Posted October 13, 2008 Relative positioning definitely has its place, as does absolute positioning. The problem is that a lot of people use relative and absolute positioning without knowing what that place is. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted October 13, 2008 Share Posted October 13, 2008 absolute positioning is awesome - provided you know what you're doing... the reason your div moves around is because your absolute positioning is doing exactly what it should. left:24%; will change (as in 24% of a smaller value) once the parent containers width has changed... Quote Link to comment Share on other sites More sharing options...
SuperBlue Posted October 13, 2008 Share Posted October 13, 2008 ToonMariner is right, absolute positioning is awesome, once you know what you are doing. The trick is that you must position the parent element to have it behave as generally wanted. A lot of beginners quickly abandon absolute positioning when they experience what you did. Above would usually mean to apply position: relative; to the parant. Below is an example of how to do this: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="eng"> <head> <title>My first Website</title> <style type="text/css"> #Basement { position: relative; width: 700px; height: 700px; } #Content { position: absolute; top: 0; right: 0; width: 400px; } </style> </head> <body> <div id="Basement"> <div id="Content"> <p>My first Website.</p> </div> </div> </body> </html> See also: CSS Position Based Layouts Note that the equal height-column layout has some outdated information, mainly regarding having a image or color fill out the canvas horizontally, this is something which there are working solutions for, i just haven't gotten around updating the Example yet. And i would also like to post an example at some point, this would mainly open up for a bottom for my underwater-layout. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.