Hi there. I have been using div float left in all my pages along with reset CSS. I would like to know what you guys think about it. The only problem I have seen with it so far is that I can not use margin:auto. Other than that it has been working great.
ronin
1:31 pm on Oct 21, 2014 (gmt 0)
What is it that you are trying to achieve, Arkan_Somar?
Are you building a fluid layout which automatically adapts itself to the amount of horizontal screen-width available?
Arkan_Somar
10:47 pm on Oct 23, 2014 (gmt 0)
I am working for a company developing software for retail stores. Part of it is cloud based and uses HTML. I worked with HTML before but never the way they do it. First thing they told me is that they float left all the divs by default. Along with resetting the CSS, something I had done before. But this floating left, is it a common practice or not? Never seen it before but works really nice.
lucy24
11:09 pm on Oct 23, 2014 (gmt 0)
they float left all the divs by default.
Yawp. Do you mean this literally? That is, the CSS says something like
div {float: left;}
? That seems like serious overkill. What about nested divs? Besides, you don't always want a left flost. Obvious example: if you've got a navigation sidebar, more likely you'd want it right-floated so it doesn't dislodge the real content on a narrow screen. (This is all assuming the site content uses a left-to-right script. Otherwise everything should get reversed.)
Along with resetting the CSS
What does "reset" mean?
ronin
11:11 pm on Oct 23, 2014 (gmt 0)
But this floating left, is it a common practice or not?
No. If you want to horizontally align <div>s in a row you can:
a) use float:left; (especially if you still need to support IE7) b) use absolute positioning (in limited cases) c) use display:inline-block; (a better solution if you're not supporting IE7) d) use CSS3 multiple columns e) use CSS3 flexbox
Arkan_Somar
12:37 am on Oct 24, 2014 (gmt 0)
Div {float:left}
In the common.CSS applied to every HTML file.
It has been working beautifully for me till now (besides the margin:auto).
When you apply the width and height to each container they occupy their position in the flow normally.
Nested divs have no issues with it.
When I mentioned reset the CSS I mean resetting some of the default values some HTML tags have. If you look online you will find there some files for this purpose.
Absolute positioning works as usual.
As I said there is only that minor issue that I have noticed to date.