Question

I have a div C inside div B inside div A.

Div A has width set to 700px, and div C has width set to 100px. Div B doesn't have the width set.

My problem is that div B extends his width to 100% (to conform div A's width). Is there a way for div B, that is, his width to conform to children divs? I want it to be wrapped around div C, and any other div I put near div C.

Was it helpful?

Solution

It sounds like what you want is the nonexistent float:center attribute. Check this article for a workaround.

OTHER TIPS

You can use the following code to achieve your result:

#b {
  margin:0px auto;
  overflow:hidden;
  display:table;
}

This should give your desired result.

Make the B div a floating element to make it's width adjust to it's children.

<div id="B" style="float:left;">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top