Reputation: 15307
I have this simple HTML and I am using tailwindcss
.
<!DOCTYPE html>
<html class="h-full" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Static Template</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="h-full">
<div id="app" class="h-full flex">
<div class="w-[312px] bg-red-100">
<h1 class="text-3xl font-bold">
Sidebar
</h1>
</div>
<div class="w-full bg-green-100">
<h1 class="text-3xl font-bold">
Main
</h1>
</div>
</div>
</body>
</html>
For some reason, my sidebar's width is not 312px like I want it to be.
What am I missing? Here is a CodeSandbox too.
Upvotes: 2
Views: 1509
Reputation: 2471
Just add flex-none
to prevent div
from growing and shrinking. Like that.
<div class="w-[312px] flex-none bg-red-100">
<h1 class="text-3xl font-bold">
Sidebar
</h1>
</div>
Upvotes: 3