Home  >  Q&A  >  body text

Bootstrap's d-flex not working properly in minimal HTML code

I'm creating a Bootstrap website, but I've run into a problem that I can't solve even with the simplest HTML (the problem is the only element on the site)... I'm desperate:

<!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>

Thanks in advance

P粉465675962P粉465675962401 days ago549

reply all(1)I'll reply

  • P粉604669414

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

    You need to include Bootstrap CSS and Bootstrap JS.

    See the code snippet below.

    <!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>

    reply
    0
  • Cancelreply