Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Any Idea of make Input and the button inline? Bootsrap v5

I want to make my input textbox and button inline but if i remove d-flex class from div, i cant justify by content to center. any ideas to make them inline or justify content?

heres my code,

<!DOCTYPE html>
<html lang="en">
  <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>Movies</title>

    <!-- Bootstrap -->

    <link
      href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
      rel="stylesheet"
      integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
      crossorigin="anonymous"
    />

    <script
      src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js"
      integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0"
      crossorigin="anonymous"
    ></script>

    <!-- css -->
    <link rel="stylesheet" href="/css/styles.css" />
  </head>
  <body class="bg-image shadow-2-strong">
    <div class="mask">
      <div
        class="
          container
          d-flex
          flex-column
          align-items-center
          justify-content-center
          text-center
          h-100
        "
      >
        <div>
          <h1 class="mb-3">THE MOVIE SCOPE!</h1>
          <h5 class="mb-4">search with movie titles</h5>
          <input type="text" class="form-control" required />
          <form action="/" method="post">
            <button type="submit" class="btn btn-outline-light btn-lg">
              click
            </button>
          </form>
        </div>
      </div>
    </div>
    <footer>
      <div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2)">
        © 2021 Copyright Danuja Jayasuriya
      </div>
    </footer>
  </body>
</html>

this is now its looks like,
https://ibb.co/8jkG75K

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Adding a div to cover <input> and <form> with the class d-flex, adding padding or margin to customize the space between textbox and button. For example, I added ms-4 to the button div.

<!DOCTYPE html>
<html lang="en">

<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>Movies</title>

  <!-- Bootstrap -->

  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous" />

  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>

  <!-- css -->
  <link rel="stylesheet" href="/css/styles.css" />
</head>

<body class="bg-image shadow-2-strong">
  <div class="mask">
    <div class="container d-flex flex-column align-items-center justify-content-center text-center h-100">
      <h1 class="mb-3">THE MOVIE SCOPE!</h1>
      <h5 class="mb-4">search with movie titles</h5>
      <div>
        <div class="d-flex">
          <input type="text" class="form-control" required />
          <form action="/" method="post">
            <button type="submit" class="btn btn-outline-light btn-lg ms-4">click</button>
          </form>
        </div>
      </div>
    </div>
  </div>
  <footer>
    <div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2)">© 2021 Copyright Danuja Jayasuriya</div>
  </footer>
</body>

</html>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading