The input box reaches its minimum size and stops shrinking

I created a search box using CSS grid that should shrink along with the page, but it's not shrinking as much as I expected.

Here is how it looks when fully extended:

https://i.sstatic.net/gQaos.png

And here is how it looks when shrunk down:

https://i.sstatic.net/4KkEi.png

How can I adjust the width of the search bar so that it shrinks enough with the page to prevent the search button from moving to the bottom?

Navbar.js

import React from 'react';
import { BsFillPersonFill } from 'react-icons/bs';
import { FiMail } from 'react-icons/fi';
import { FaPlus, FaSearch } from 'react-icons/fa';
import { AiTwotoneBell } from 'react-icons/ai';
import './navbar.css';
function Navbar() {
  return (
    <nav id="nav-bar">
      <div className="container">
        <h2 className="homeBtn">VIZZEY</h2>
        <div className="search">
          <input type="search" className="form-control" />
          <button className="searchBtn">o</button>
        </div>
        <ul className="ugh-buttons">
          <li className="btn">
            <button className="icon-btn">lol</button>
          </li>
          <li className="btn">
            <button className="icon-btn">lol</button>
          </li>
          <li className="btn">
            <button className="icon-btn">lol</button>
          </li>
          <li className="btn">
            <button className="icon-btn">lol</button>
          </li>
        </ul>
      </div>
    </nav>
  )
}
export default Navbar;

Navbar.css

* {
    margin: 0;
} 

ul {
    list-style: none; 
    display: flex; 
} 

a {
    text-decoration: none; 
    color: #fff;
} 

.homeBtn {
    height: 55px; 
    text-align: center; 
    justify-content: center; 
    padding: auto; 

}

#nav-bar {
    background-color: #888888;
    overflow: hidden;
} 

.container {
    display: grid; 
    grid-template-columns: 1fr 6fr 1fr;
    align-items: center;
} 

ul li a {
    padding: 1.6rem;
    font-weight: bold;
}

.form-control {
    background-color: rgb(255, 255, 255); 
    border-color: rgb(133, 133, 133);  
    border-top-left-radius: 5px !important;
    border-bottom-left-radius: 5px !important; 
    height: 38px; 
    width: 90%;
    flex: auto;
    border: none; 
    padding-left: 10px;  
    justify-content: center;
}

.homeBtn {
    background-color: #00ce7f;
} 

.search {
  padding-left: 10px; 
}
.btn { 
    padding-right: 10px; 
} 

.ugh-buttons {
margin-right: 10px;
}

.icon-btn {
    height: 40px; 
    width: 40px; 
    border-radius: 5px; 
    background-color: #00ce7f;
    color: white; 
    border: none; 
    padding-left: 5px;
}

button:active {
    outline: none !important;
    box-shadow: none !important; 
    background-color: rgb(111, 0, 255);
} 

button:active {
    outline: none !important;
    box-shadow: none !important; 
    background-color: rgb(111, 0, 255);
} 

button:focus {
    outline: none !important;
    box-shadow: none !important; 
}

button:hover {
    cursor: pointer;
} 

.searchBtn {
    color: #fff;
    background-color: #00ce7f;
    height: 38px; 
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px; 
    width: 40px;   
    border: none;  
    font-weight: bold;
}       

.buttons {
    color: #fff;
    background-color: #00ce7f;
    height: 38px; 
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px; 
    border-top-left-radius: 5px; 
    border-bottom-left-radius: 5px; 
   text-align: center;
    width: 40px;   
    border: none; 
    font-size: large; 
    font-weight: bold;
}
 
[type="search"]::-webkit-search-cancel-button,
[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

input {
    outline: none;
}

Answer â„–1

Consider incorporating the display: flex property into the .search class:

* {
  margin: 0;
}

ul {
  list-style: none;
  display: flex;
}

a {
  text-decoration: none;
  color: #fff;
}

.homeBtn {
  height: 55px;
  text-align: center;
  justify-content: center;
  padding: auto;

}

#nav-bar {
  background-color: #888888;
  overflow: hidden;
}

.container {
  display: grid;
  grid-template-columns: 1fr 6fr 1fr;
  align-items: center;
}

ul li a {
  padding: 1.6rem;
  font-weight: bold;
}

.form-control {
  background-color: rgb(255, 255, 255);
  border-color: rgb(133, 133, 133);
  border-top-left-radius: 5px !important;
  border-bottom-left-radius: 5px !important;
  height: 38px;
  width: 90%;
  flex: auto;
  border: none;
  padding-left: 10px;
  justify-content: center;
}

.homeBtn {
  background-color: #00ce7f;
}

.search {
  padding-left: 10px;
  display: flex;             /* added */
}

.btn {
  padding-right: 10px;
}

.ugh-buttons {
  margin-right: 10px;
}

.icon-btn {
  height: 40px;
  width: 40px;
  border-radius: 5px;
  background-color: #00ce7f;
  color: white;
  border: none;
  padding-left: 5px;
}

button:active {
  outline: none !important;
  box-shadow: none !important;
  background-color: rgb(111, 0, 255);
}

button:active {
  outline: none !important;
  box-shadow: none !important;
  background-color: rgb(111, 0, 255);
}

button:focus {
  outline: none !important;
  box-shadow: none !important;
}

button:hover {
  cursor: pointer;
}

.searchBtn {
  color: #fff;
  background-color: #00ce7f;
  height: 38px;
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
  width: 40px;
  border: none;
  font-weight: bold;
}

.buttons {
  color: #fff;
  background-color: #00ce7f;
  height: 38px;
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
  text-align: center;
  width: 40px;
  border: none;
  font-size: large;
  font-weight: bold;
}

[type="search"]::-webkit-search-cancel-button,
[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

input {
  outline: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<nav id="nav-bar">
  <div class="container">
    <h2 class="homeBtn">VIZZEY</h2>
    <div class="search">
      <input type="search" class="form-control" />
      <button class="searchBtn">o</button>
    </div>
    <ul class="ugh-buttons">
      <li class="btn">
        <button class="icon-btn">lol</button>
      </li>
      <li class="btn">
        <button class="icon-btn">lol</button>
      </li>
      <li class="btn">
        <button class="icon-btn">lol</button>
      </li>
      <li class="btn">
        <button class="icon-btn">lol</button>
      </li>
    </ul>
  </div>
</nav>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Guide: Utilizing ng-repeat in Ionic framework for displaying nested JSON objects

Currently in the process of developing a basic hybrid mobile application using the Ionic framework. The main functionality involves sending a GET request to retrieve matching last names when searched for, and then displaying their corresponding ID's. ...

AngularJS is throwing a $injector:modulerr error and I've exhausted all possible solutions

I recently started learning Angular and I've been following the tutorial on the official AngularJS website. Here's what I've tried so far: Installed angular-route and included the script below angular.min.js Utilized ngRoute in my mod ...

What is the best way to run a scheduled task automatically using node-cron?

I have a custom function that saves data to the database using the POST method. When testing it with Postman, I send an empty POST request to trigger the controller. Upon execution, the function triggers two more functions. One of them is responsible for ...

Is there a way to prevent advertisements from appearing in npm?

As I execute various npm commands, my console gets bombarded with ads promoting different projects and individuals. While I enjoy contributing to open source projects, I believe the console output of a tool should not be used for advertising. Thank you fo ...

Tips for Ensuring Proper Functionality of the LIKE Button on Both Client and Server Sides

On my webpage, there is a 'LIKE' Button below each post. Clicking the 'LIKE' button triggers a GET request via AJAX to a like.php page that adds a row to a MySQL database table. Once the button has been clicked by a user, it disappears. ...

When adjusting the max-height and overflow-y in a Boostrap 4 Navbar with a search input/icon placement set to absolute position, the functionality seems to break

While attempting to create a search input with an embedded search icon that works within the Bootstrap 4 navbar when the mobile menu is displayed, I encountered some challenges. The process was much simpler in my previous version using Bootstrap 3... http ...

Creating a scrollable nested div on a mobile website

Is there a way to achieve a scrollable nested div on a jQuery mobile site? I am aiming for a fixed header and footer with the middle section being scrollable. Despite my attempts to set overflow:scroll (along with specifying the width and height of the div ...

Having trouble positioning the button on the right side of the page and aligning the text in the center of the page

Having trouble positioning the button to the right of the page and aligning the text in the center, despite adding CSS properties such as float: right. <div id="project-heading" style = "margin-top: 0px; padding-bottom: 0px;margin-bottom: 0px ; padd ...

Is the Bootstrap carousel sliding to the top after clicking the next and previous buttons?

Here is the carousel I created using Bootstrap: <div id="carouselExample" class="carousel slide d-none d-sm-none d-md-block" data-ride="carousel"> <div class="carousel-inner"> <div class="carousel-item active ...

Creating a Versatile Data Retrieval Hook in TypeScript for APIs with Diverse Response Formats

Currently, I am undertaking a movie discovery project that involves fetching data from two APIs: Tmdb movie site. These APIs have different response structures—one for movies and one for genres. In order to streamline my code and avoid repeating the same ...

Vertically align an image of unknown height using CSS, ensuring compatibility with IE9

.box { width : 100%; max-height : 300px; overflow : hidden; } img { width : 100%; } <div class="box"> <img src="banner.png" /> </div> I am faced with a challenge regarding the sizing of the image banner.png wit ...

What is the best way to adjust the size of an image within a hyperlink using jQuery?

I'm trying to grab an image from a hyperlink and resize it for display to the user. I've written the code below, but it's not working as expected. Can anyone lend a hand? if ($(this).find("img").attr("src") != null) { va ...

Navigating memory in Three.js while handling multiple textures

I am in the process of developing a fairly straightforward Three.js Application. Overview: The concept involves navigating with your camera along a path through a virtual "world". This world consists entirely of basic Sprites with SpriteMaterials adorned ...

JavaScript Bridge function in WebView not invoked

I encountered a strange issue with my application, which functions as an e-reader. To invoke functions for the web view, I utilize a JavaScript class: public class MyJavaScriptInterface { Context mContext; /* Instantiate the interface ...

A versatile jQuery function for extracting values from a :input selector

Is there a universal method in jQuery to retrieve the value of any :input element? I pose this question because I have a webpage containing select and checkbox inputs, as seen in the code below: for (var i = 0; i < arguments.length; i++) { ...

Load jQuery DataTable when the event changes

I have implemented a script that loads the DataTable when the page is ready: function initializeDataTable(serviceUrl) { var $dataTable = $('#example1').DataTable({ "ajax": serviceUrl, "iDisplayLength": 25, "order": [[2, "asc"]], ...

Sinon's fakeTimers failing to trigger

I'm encountering an issue with sinon's fakeTimers while working in a setup that includes Marionette.js, underscore, and chai test runner. Strangely, when I place a breakpoint in Chrome and step through the code, my timer functions as expected. Ho ...

Sign in alert for main page module connections

I need to set up a login-pop-up window to appear when a user clicks on links within a custom module. Currently, I am using rokbox to display the pop-up for other links, but I want it specifically for certain links within this module. If the user is not log ...

Issue encountered when attempting to activate a Vue function in order to update a specific component's field

Let me preface this by saying that I am new to Vue.js and still learning the ropes. Here's what I'm trying to achieve: I have a label and a button. The behavior I want is that when the label is not visible, the button should display "Show Label" ...

Error message Subscription UnauthorizedException appears when attempting to update model. Need help to disable subscription?

After updating my AWS Amplify front end (NextJS) to remove subscriptions on a custom "Card" object in my schema.graphql file, I am still encountering warnings in the developer console regarding authorization issues when trying to update the "Card" model. I ...