April 20, 2012

Getting Div's to align side by side in narrow browser

Question by Dave

http://jsfiddle.net/ZGhEe/

I’ve read several tutorials and they all say use float or use relative positioning, but all the techniques I try aren’t giving me expected results. This is a pretty simple thing to do, but I want to do it the “correct” way since using html tables is punishable by death. Any help?

If I use float left it stacks unnecessarily when the browser gets narrow..

Answer by Lie Ryan

When using float and you want it to show side-by-side, you need to set the width and make sure the sum of the widths are less than the width of the container, like so.

Answer by Starx

If you want to make your browser fit it all of the browser. Make your browser fluid.

i.e. Give % while defining the width of the layout.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!