Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

floated elements nested in centered div

Featured Replies

Hello,

 

Im having difficulty with a CSS layout. I have a centered container div with a 'margin:auto' property, and then two nested column divs for nav and content inside. Once i float these nested divs (left & right) they come away from there parent conatiner div. What is the correct way of coding this? Here is a snippit of my code:

 

#container  {margin:auto;
                  width:850px; 
                  height:100%;
    }

#navigation { width:250px; 
     height:500px;
                    float:left;
   }

#content { width:500px;
                height:500px;
 float:right;
	  }

 

hope that makes sence :rolleyes:

try float both of them left, rather than left+right

 

it should work, as a method btw

  • Author

Same thing happens, the nested elements are not sitting in the container at all, could be something to do with the parent div not being floated, so they come away from it.

When you say 100% on the container properties - 100% of what? If you haven't declared a height for, say the body, the total height of the container might be less than it's children, and not expanding to accomadating them? Just a thought.....

Theres is no %100 tag for height, its not possible to declare this tag it can only be %100 width, you have to specify a certain height. Wat does you html look like that could also be the problem.

Theres is no %100 tag for height, its not possible to declare this tag it can only be %100 width, you have to specify a certain height.

 

If that were true, then how would liquid 3 column etc. layouts be possible?

That's because the three columns are "columns", and each expands to the height of the content in each column.

 

If you wanted to give the impression that the columns are of equal height, say by using background colours, it is possible but there are numerous ways to achieve the effect - too many to go into here :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.