How to Create a Two-Column Layout with a Fixed-Width Right Column
In web design, it's often necessary to create a layout with two columns, one of which has a fixed width while the other is fluid. Despite being a common requirement, finding a solution that works consistently can be challenging.
In this specific case, the goal is to create two columns where the right column maintains a constant width while the left column expands or contracts based on the available space. Here's a step-by-step answer:
Example HTML:
<div class="container"> <div class="right"> Right Content (Fixed Width) </div> <div class="left"> Left Content (Flexible Width) </div> </div>
CSS:
.container { height: auto; overflow: hidden; } .right { width: 180px; float: right; background: #aafed6; } .left { float: none; background: #e8f6fe; width: auto; overflow: hidden; }
This solution creates the desired two-column layout with a fixed-width right column while allowing the left column to adjust dynamically based on the browser window size.
The above is the detailed content of How to Create a Two-Column Layout with a Fixed-Width Right Column?. For more information, please follow other related articles on the PHP Chinese website!