源代码:
下载代码
AI 编程工具
点击运行
<!doctype html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="https://cdn.tailwindcss.com"></script> </head> <body> <div class="relative rounded-xl overflow-auto p-8"> <p>使用 flex-initial</p> <div class="mt-2 flex gap-4 text-white text-sm font-bold font-mono leading-6 bg-stripes-blue rounded-lg"> <div class="p-4 flex-none w-14 h-14 rounded-lg flex items-center justify-center bg-blue-300 dark:bg-blue-800 dark:text-blue-500">01</div> <div class="p-4 flex-initial w-24 sm:w-64 rounded-lg flex items-center justify-center bg-blue-500 shadow-lg">02</div> <div class="p-4 flex-initial w-14 sm:w-32 rounded-lg flex items-center justify-center bg-blue-500 shadow-lg">03</div> </div> <p>使用 flex-1</p> <div class="mt-2 flex gap-4 text-white text-sm font-bold font-mono leading-6 bg-stripes-pink rounded-lg"> <div class="p-4 flex-none w-14 h-14 rounded-lg flex items-center justify-center bg-pink-300 dark:bg-pink-800 dark:text-pink-400">01</div> <div class="p-4 flex-1 w-64 rounded-lg flex items-center justify-center bg-pink-500 shadow-lg">02</div> <div class="p-4 flex-1 w-32 rounded-lg flex items-center justify-center bg-pink-500 shadow-lg">03</div> </div> <p>使用 flex-auto</p> <div class="mt-2 flex gap-4 text-white text-sm font-bold font-mono leading-6 bg-stripes-violet rounded-lg"> <div class="p-4 flex-none w-14 h-14 rounded-lg flex items-center justify-center bg-violet-300 dark:bg-violet-800 dark:text-violet-400">01</div> <div class="p-4 flex-auto w-64 rounded-lg flex items-center justify-center bg-violet-500 shadow-lg">02</div> <div class="p-4 flex-auto w-32 rounded-lg flex items-center justify-center bg-violet-500 shadow-lg">03</div> </div> </div> </body> </html>
运行结果: