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.
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
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
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
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.
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
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
Looks like ill need to start learning positioning Not exactly sure what the difference beteen absolute and relative positioning are.
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;"
you just need margiin-left: auto; and margin-right: auto; to center blocks , no need to position things just for the sake of centered content