Question Details

No question body available.

Tags

html css flexbox

Answers (2)

Accepted Answer Available
Accepted Answer
July 20, 2026 Score: 2 Rep: 761 Quality: Medium Completeness: 50%

The problem is likely that the is still using its default inline layout. Your flex styling is on .search-container, not on the that actually contains the input and button.

Try making the form itself a flex container:

.search-container form {
  display: flex;
  align-items: center;
}

Also check the default button styles in your browser. Some browsers add their own padding or alignment, which can make the button appear slightly higher.

One other thing: a

shouldn't be a direct child of a
    . Wrap the search form in an
  • instead to keep the HTML valid

    July 20, 2026 Score: 2 Rep: 1,900 Quality: Low Completeness: 60%

    You're almost there. Just need to add form in the css of .search-container.

    Also, I have added height: 36px to search container and form element.

    header {
      width: 100%;
      padding: 0;
      margin: 0;
    }

    .top-nav { position: relative; / needed so ul::after (LINE)is positioned relative to the whole nav / width: 100%; / make the nav span the page width / box-sizing: border-box; font-family: Roboto, sans-serif; font-size: 18px; list-style-type: none; margin: 0; padding: 0; background-color: white; display: flex; gap: 15px; / ignore margin / }

    .top-nav .search-container { margin-left: auto; display: flex; align-items: center;

    / enable bottom to work and keep the search above the grey bar / position: relative; z-index: 1;

    height: 36px; }

    .top-nav .search-container form { display: flex; align-items: center; height: 36px; }

    .top-nav input[type="text"] { padding: 2px; margin: 0; height: 36px; font-size: 17px; border: 2px solid #ccc; border-right: none; / removed right border so it joins the button / border-top-left-radius: 4px; border-bottom-left-radius: 4px; border-top-right-radius: 0; border-bottom-right-radius: 0; box-sizing: border-box; }

    .top-nav .search-container button { padding: 0; margin: 0; / removed horizontal spacing so it sticks to the input / width: 36px; height: 36px; background: #ddd; font-size: 17px; border: 2px solid #ccc; / match input border / border-left: none; / remove left border so it joins the input / border-top-right-radius: 4px; border-bottom-right-radius: 4px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }

    .top-nav .search-container button:hover { background: #ccc; }