搜索

首页  >  问答  >  正文

最小的HTML代码中,Bootstrap的d-flex无法正常运行

我正在创建一个Bootstrap网站,但是我已经遇到了一个问题,即使使用最简单的HTML也无法解决这个问题(这个问题是网站上唯一的元素)...我感到绝望:

<!DOCTYPE html>
<html lang="fr">
<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>Association Capucine - Gagner contre la leucémie</title>
</head>
<body>
  <div class="d-flex justify-content-around">
    <div class="p-2 bg-info">Flex item 1</div>
    <div class="p-2 bg-warning">Flex item 2</div>
    <div class="p-2 bg-primary">Flex item 3</div>
  </div>
  <main>
  </main>
  <footer>
  </footer>
</body>

</html>

提前感谢

P粉465675962P粉465675962471 天前599

全部回复(1)我来回复

  • P粉604669414

    P粉6046694142023-09-14 16:30:44

    您需要包含Bootstrap CSS和Bootstrap JS。

    请参见下面的代码片段。

    <!DOCTYPE html>
    <html lang="fr">
    
    <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>Association Capucine - Gagner contre la leucémie</title>
      <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
    </head>
    
    <body>
      <div class="d-flex justify-content-around">
        <div class="p-2 bg-info">Flex item 1</div>
        <div class="p-2 bg-warning">Flex item 2</div>
        <div class="p-2 bg-primary">Flex item 3</div>
      </div>
    
      <main>
      </main>
    
      <footer>
      </footer>
    
      <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
    </body>
    
    </html>

    回复
    0
  • 取消回复