Home > Net >  Nav items are not aligned in mobile view
Nav items are not aligned in mobile view

Time:12-12

My navitems are taking up two lines when I shrink my screen to mobile view. The search bar and hamburger menu and the logo are all in different places, I want them in a single line.

mobile view:

enter image description here

desktop view:

enter image description here Any input will be appriciated.

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <link rel="apple-touch-icon" sizes="57x57" href="images/apple-icon-57x57.png">
    <link rel="apple-touch-icon" sizes="60x60" href="images/apple-icon-60x60.png">
    <link rel="apple-touch-icon" sizes="72x72" href="images/apple-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="76x76" href="images/apple-icon-76x76.png">
    <link rel="apple-touch-icon" sizes="114x114" href="images/apple-icon-114x114.png">
    <link rel="apple-touch-icon" sizes="120x120" href="images/apple-icon-120x120.png">
    <link rel="apple-touch-icon" sizes="144x144" href="images/apple-icon-144x144.png">
    <link rel="apple-touch-icon" sizes="152x152" href="images/apple-icon-152x152.png">
    <link rel="apple-touch-icon" sizes="180x180" href="images/apple-icon-180x180.png">
    <link rel="icon" type="image/png" sizes="192x192"  href="images/android-icon-192x192.png">
    <link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="96x96" href="images/favicon-96x96.png">
    <link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png">
    <link rel="manifest" href="images/manifest.json">
    <meta name="msapplication-TileColor" content="#ffffff">
    <meta name="msapplication-TileImage" content="images/ms-icon-144x144.png">
    <meta name="theme-color" content="#ffffff">
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <link rel="stylesheet" href="styles.css">
    <title>Rento</title>
  </head>
  <body>
  <nav >
    <a  href="#">
      <img  src="images/logo.jpeg" alt="Rento" width="70" height="70" >
    </a>
    <button  type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
      <span ></span>
    </button>
    <div >
      <div >
        <input  type="search" placeholder="Search" aria- 
 label="Search" autofocus="autofocus" autocomplete="off">
        <span >
          <button  type="button" name="button">Search</button>
        </span>
      </div>
    </div>
    <div  id="navbarTogglerDemo01">
      <ul >
        <li ><a  href="#">Signin</a></li>
        <li ><a  href="#">Cart</a></li>
        <li ><a  href="#">About</a></li>
        <li ><a  href="#">Testimonials</a></li>
        <li ><a  href="#">Contact</a></li>
      </ul>
   </nav>
</div>
  </body>
</html>

CodePudding user response:

I change col-11 to col-6 for search-box.

<div >

so in this case you can use col-6 in all devices.

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

<head>
  <meta charset="utf-8">
  <link rel="apple-touch-icon" sizes="57x57" href="images/apple-icon-57x57.png">
  <link rel="apple-touch-icon" sizes="60x60" href="images/apple-icon-60x60.png">
  <link rel="apple-touch-icon" sizes="72x72" href="images/apple-icon-72x72.png">
  <link rel="apple-touch-icon" sizes="76x76" href="images/apple-icon-76x76.png">
  <link rel="apple-touch-icon" sizes="114x114" href="images/apple-icon-114x114.png">
  <link rel="apple-touch-icon" sizes="120x120" href="images/apple-icon-120x120.png">
  <link rel="apple-touch-icon" sizes="144x144" href="images/apple-icon-144x144.png">
  <link rel="apple-touch-icon" sizes="152x152" href="images/apple-icon-152x152.png">
  <link rel="apple-touch-icon" sizes="180x180" href="images/apple-icon-180x180.png">
  <link rel="icon" type="image/png" sizes="192x192" href="images/android-icon-192x192.png">
  <link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="96x96" href="images/favicon-96x96.png">
  <link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png">
  <link rel="manifest" href="images/manifest.json">
  <meta name="msapplication-TileColor" content="#ffffff">
  <meta name="msapplication-TileImage" content="images/ms-icon-144x144.png">
  <meta name="theme-color" content="#ffffff">
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
  <link rel="stylesheet" href="styles.css">
  <title>Rento</title>
</head>

<body>
  <nav >
    <a  href="#">
      <img  src="images/logo.jpeg" alt="Rento" width="70" height="70">
    </a>
    <div >
      <div >
        <input  type="search" placeholder="Search" aria- label="Search" autofocus="autofocus" autocomplete="off">
        <span >
          <button  type="button" name="button">Search</button>
        </span>
      </div>
    </div>
    <button  type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
          <span ></span>
        </button>
    <div  id="navbarTogglerDemo01">
      <ul >
        <li ><a  href="#">Signin</a></li>
        <li ><a  href="#">Cart</a></li>
        <li ><a  href="#">About</a></li>
        <li ><a  href="#">Testimonials</a></li>
        <li ><a  href="#">Contact</a></li>
      </ul>
  </nav>
  </div>
</body>

</html>

CodePudding user response:

This is because the length of your search tab is large.To align the elements in a single line adjust the size of the search tab. This would help with this issue. Here I have just provided the code for your reference

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <link rel="apple-touch-icon" sizes="57x57" href="images/apple-icon-57x57.png">
    <link rel="apple-touch-icon" sizes="60x60" href="images/apple-icon-60x60.png">
    <link rel="apple-touch-icon" sizes="72x72" href="images/apple-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="76x76" href="images/apple-icon-76x76.png">
    <link rel="apple-touch-icon" sizes="114x114" href="images/apple-icon-114x114.png">
    <link rel="apple-touch-icon" sizes="120x120" href="images/apple-icon-120x120.png">
    <link rel="apple-touch-icon" sizes="144x144" href="images/apple-icon-144x144.png">
    <link rel="apple-touch-icon" sizes="152x152" href="images/apple-icon-152x152.png">
    <link rel="apple-touch-icon" sizes="180x180" href="images/apple-icon-180x180.png">
    <link rel="icon" type="image/png" sizes="192x192"  href="images/android-icon-192x192.png">
    <link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="96x96" href="images/favicon-96x96.png">
    <link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png">
    <link rel="manifest" href="images/manifest.json">
    <meta name="msapplication-TileColor" content="#ffffff">
    <meta name="msapplication-TileImage" content="images/ms-icon-144x144.png">
    <meta name="theme-color" content="#ffffff">
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <link rel="stylesheet" href="styles.css">
    <title>Rento</title>
  </head>
  <body>
  <nav >
    <a  href="#">
      <img  src="images/logo.jpeg" alt="Rento" width="70" height="70" >
    </a>
    <button  type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
      <span ></span>
    </button>
    <div >
      <div >
        <input  type="search" placeholder="Search" aria- 
 label="Search" autofocus="autofocus" autocomplete="off">
        <span >
          <button  type="button" name="button">Search</button>
        </span>
      </div>
    </div>
    <div  id="navbarTogglerDemo01">
      <ul >
        <li ><a  href="#">Signin</a></li>
        <li ><a  href="#">Cart</a></li>
        <li ><a  href="#">About</a></li>
        <li ><a  href="#">Testimonials</a></li>
        <li ><a  href="#">Contact</a></li>
      </ul>
   </nav>
</div>
  </body>
</html>

  • Related