- This topic is empty.
December 19, 2013 at 6:59 am #158731
Hello friends, i am trying to set up a two column layout with a static left column-menu and a right column fluid scrolable. Here is an example:
The layout looks good when viewing it in 900px + width browser, but if you try resize the browser and make it smaller the content breaks.
Any help would be appreciatedDecember 19, 2013 at 7:25 am #158736paulobParticipant
You will rarely use position:relative to move elements structurally as it doesn’t really move the element at all. It just makes the element appear somewhere else but it always preserves the space it previously occupied. That means that all elements on the page react as though the relative element hadn’t been moved at all.
You just need to use margin-left:211px on your section element and not left:211px (also note that globally setting rules for your section element is not a good idea either as that means you can never use another section element without undoing all the styles you have applied. Add a class to the section element and use the class to style it.)
Generally it is not a good idea to use absolute columns either because that means you must forever control the height. Floating the column would be better and then regaining the flow after the float by containing and clearing.
In your case you have triggered a vertical scrollbar so you will probably be ok as you are controlling the height. However scrollbars on inner elements are usually undesirable and its better to let content dictate the height and not fix it in px. Of course there are always exceptions depending on the design.December 19, 2013 at 7:36 am #158739
Thanx for the reply! margin-left solved the problem. I will use classes for styling section element etc this is just a draft.
I want the design to be exactly as viewed. I have tried to float the menu column but it scrolls with the content at the same time. I need the menu to be static in its position. Can you please give me a quick layout with floats?
ThanxDecember 19, 2013 at 7:41 am #158740
I forgot to mention that finally the layout will be full responsiveDecember 19, 2013 at 8:12 am #158742paulobParticipant
If you want the menu to be static while you scroll the other column then you may as well use absolute positioning as you have done. Especially if you just have that small left column. (There would be issues if you didn’t control the height and the left column was taller than the right.)
I was assuming that it would be a normal page where everything scrolls.
You may still want to set the height in ems and not px so that if users zoom the text then everything grows together.December 19, 2013 at 8:57 am #158747
Ok mate thanx for your time and suggestions! cheers!
- The forum ‘CSS’ is closed to new topics and replies.