Home > front end >  Any Idea of make Input and the button inline? Bootsrap v5
Any Idea of make Input and the button inline? Bootsrap v5

Time:12-29

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/[email protected]/dist/css/bootstrap.min.css"
      rel="stylesheet"
      integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
      crossorigin="anonymous"
    />

    <script
      src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
      integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0"
      crossorigin="anonymous"
    ></script>

    <!-- css -->
    <link rel="stylesheet" href="/css/styles.css" />
  </head>
  <body >
    <div >
      <div
        
      >
        <div>
          <h1 >THE MOVIE SCOPE!</h1>
          <h5 >search with movie titles</h5>
          <input type="text"  required />
          <form action="/" method="post">
            <button type="submit" >
              click
            </button>
          </form>
        </div>
      </div>
    </div>
    <footer>
      <div  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

CodePudding user response:

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/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous" />

  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>

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

<body >
  <div >
    <div >
      <h1 >THE MOVIE SCOPE!</h1>
      <h5 >search with movie titles</h5>
      <div>
        <div >
          <input type="text"  required />
          <form action="/" method="post">
            <button type="submit" >click</button>
          </form>
        </div>
      </div>
    </div>
  </div>
  <footer>
    <div  style="background-color: rgba(0, 0, 0, 0.2)">© 2021 Copyright Danuja Jayasuriya</div>
  </footer>
</body>

</html>

  • Related