html 为什么内部元素的风格不适用于顺风?

weylhg0b  于 2023-04-18  发布在  其他
关注(0)|答案(1)|浏览(142)
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="head.css">
    
</head>
<body>
    <div class="grid grid-cols-10">
        <div class="col-start-1 col-end-3 bg-slate-600 h-screen"></div>
        <div class="col-span-8">
            <div class="p-4 bg-slate-400 m-4 h-screen">
                <div class="bg-yellow-100 m-4 ">Hello</div>
            </div>
        </div>
        
    </div>

</body>

我需要在灰色部分添加标题,但效果不适用于那里!黄色背景不出现,只显示文本Image with error它工作正常,如果在包括

<script src="https://cdn.tailwindcss.com"></script>

但不是和

<link rel="stylesheet" href="head.css">

(使用tailwind CLI)

bcs8qyzn

bcs8qyzn1#

您可能没有将Tailwind包含到您的项目中。上面的代码按预期工作。您只需要在<head>中添加<script src="https://cdn.tailwindcss.com"></script>
请参见下面的片段。

<!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="grid grid-cols-10">
    <div class="col-start-1 col-end-3 bg-slate-600 h-screen"></div>
    <div class="col-span-8">
      <div class="p-4 bg-slate-400 m-4 h-screen">
        <div class="bg-yellow-100 m-4 ">Hello</div>
      </div>
    </div>
  </div>
</body>

</html>

相关问题