1. The parent element doesn't collapse if no height stipulated. 2. This adds a few pixels spacing between the divs. 3. When I add margin-top of 20px to div_2 it adds it to div_1 and div_3. 4. When I add padding-top of 40px to div_2 it simulates adding a margin-top of 40px to div_1 and div_3. (How would I get div_1 and 3 back up?)
Using the float method I always stipulate the parent elements height to negate the collapsing issue and it always seems fine.
But if I need to change it all to use the display: inline-block method the comments I've made would really cause me an issue. As you can notice as soon as I started to add margins and padding all sorts of issues were produced. I even put another div inside the div 2 and added the margins and padding to that but still didn't change it's behaviour.
What I'd really like to know is, is it ok to use the float method or do I need to start from the beginning learning css.
If I do any pointers as to how to make the display: inline-block script display the same as the float script would be a really helpful start.
Msg#: 4581387 posted 8:55 pm on Jun 5, 2013 (gmt 0)
"float" and "inline-block" are different things used for different purposes.
Here as elsewhere, it tends to work better if you first figure out, in English (or human language of your choice), what you want the element to do and how you want it to behave in different circumstances. And then set up the code to make it do what you want.
So you can't lay down a general rule saying Always A or Always B. Code for the specific situation.
Msg#: 4581387 posted 9:17 am on Jun 6, 2013 (gmt 0)
Thanks for the reply and confirming that using float is a perfectly correct method of coding. I'm building my first on-line application and using float did everything I wanted but when I read this debate some of the experienced designers were making comments like
"Floating divs next to each other is a new method of using tables and like tables they will be extinct soon"
"One even said they never ever use float and if you did it shows you know nothing about designing websites"
This is what I needed to clear up which you have done. Thanks for putting my mind at rest and I can now look forward to spending the day producing rather than double checking what I've already done.
Msg#: 4581387 posted 1:29 pm on Jun 7, 2013 (gmt 0)
Thanks for seconding the advice Lucy gave me. One of the main reasons I joined WebmasterWorld is because of "the advice" I've found on the net.
As a non-trained person I read books and search the net in order to learn the technology to be able to build the applications I want. But the amount of times I've tried something only to find for instance it was incorrect advice or browser compatibility was not taken into consideration or something else or something else has made a complex task a lot harder.
When I read you shouldn't even use floats I couldn't believe it, due to my lack of experience it made me think everything that I'd done to date was wrong, you can imagine what my first thoughts were.
So thank you both for the advice and enabling me to move forward instead of spending my time analysing information that makes no sense.