I'm going crazy trying to choose the following layout correctly:
- fixed width left div (maybe multiple divs one next to the other)
- central div with automatic width (takes up the remaining space)
- fixed width right div (maybe multiple divs one next to the other)
- there must be a border between the center div and the first neighbor, whether it is left or right
HTML
<div class="container"> <div class="all left"> Left1 </div> <div class="all left"> Left2 </div> <div class="all center"> Center </div> <div class="all right"> Right1 </div> <div class="all right"> Right2 </div> </div>
CSS
.container { display: table; position: relative; width: 100%; height: 100px; border-spacing: 5px; } .all { display: table-cell; border: 1px solid #333; margin: 5px; } .left { width: 45px; } .right { width: 45px; } .center { width: auto; }
Fiddle
http://jsfiddle.net/ozrentk/VdryG/3/
However, no matter what I try (for example, putting border-spacing: 0px in the left or right div, margin: 0 , dropping borders), all my fields end up the same.
To simplify this, I want:
+--------------------------------------------------------------+ |+-----++-----+ +------------------------------++-----++-----+| || || | | || || || || || | | || || || || || | | || || || || || | | || || || || || | | || || || || || | | || || || || || | | || || || || || | | || || || |+-----++-----+ +------------------------------++-----++-----+| +--------------------------------------------------------------+
But currently I have this:
+--------------------------------------------------------------+ | | | +----+ +----+ +--------------------------+ +----+ +----+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +----+ +----+ +--------------------------+ +----+ +----+ | | | +--------------------------------------------------------------+
How can I manage individual fields in this layout?
PS
- I don't want a solution with mixing floats with non-floats because it ends up with layout problems, see this
- I don't want a solution using css calc because it is experimental
- I do not want a JS solution because I think CSS should be used for such a layout and can lead to flickering; In addition, the user can disable JS
source share