WeCode
Academy
Tutorials
Web Development
Bootstrap
CSS
HTML
JavaScript
jQuery
Node.js
PHP
React
TypeScript
Programming
C
C#
C++
Go
Java
Python
Rust
Data and Databases
NumPy
Pandas
SQL
Tools
Bash
Git
Projects
Project: A Tiny Shell in C
Project: Bank Account System
Project: Library Management System
Project: Portfolio Page
Project: Quiz App in React
Project: Sales Data Analysis
Project: Server Log Analyser
Project: To-Do REST API
Project: URL Shortener
Project: Word Counter in Four Languages
All tutorials ❯
Paths
References
Practice
Try it editor
Quizzes
How To recipes
Tools
Glossary
My Learning
🌙
Dark mode
Home
›
How To
›
CSS
Create a sidebar layout
A two-column grid with a fixed sidebar and a flexible main area.
Example
html
<style> .layout { display: grid; grid-template-columns: 140px 1fr; gap: 12px; min-height: 140px; } .side { background: #e7f9f1; padding: 10px; } .main { background: #f1f3f5; padding: 10px; } </style> <div class="layout"><div class="side">Sidebar</div><div class="main">Main content grows to fill the space.</div></div>
Run ❯
Reset
Open in editor »
More CSS recipes
Center a div horizontally and vertically
Make a sticky header
Create a responsive grid of cards
Style a button with a hover effect
Build a pure CSS tooltip