CSS Tricks : Perfect Liquid Layout with Fixed Width Right Column Doing a fixed width left column is easy, but doing a fixed width right column in a liquid layout is a bit tricky. We need to use a container div and give that div negative margin, then give the left column div the same amount of positive margin to get it to display right. Our example also takes into account we want padding in each column along with spacing between them. CSS
HTML
Result: Mouse-over below to see the liquid column in action! Liquid Column
Fixed Column
Be sure to increase the margin values in .left-column and .left-column-cont with any padding you add to either of the columns and add in the desired spacing between the columns. In our example, we give 10px of padding to both columns (padding occurs 4 times on left and right of both columns.) and we want 20px space
between them. The liquid column will always size correctly to the parent's element width. If using a fixed width layout, you don't need to go to this extreme to get perfect columns. However, if using a liquid layout such as in a responsive design, this is the way to do it. Published by: Thomas Penwell Initially published on: August 10, 2015 Article last modified on: Friday, August 14, 2015. |
||