What is preventing the input box from shrinking further?

I created a search box using CSS grid that is supposed to shrink when the page is resized. However, it doesn't seem to shrink as much as I expected it to.

Here is how it appears when fully extended: https://i.stack.imgur.com/tPuCg.png And here is how it looks when the page is shrunk: https://i.stack.imgur.com/8vnj5.png

Navbar.styling

* {
    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;
}

Navbar.interactions

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" placeholder="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;

Any suggestions on how to make the search bar shrink enough while keeping the button intact on the side?

Answer №1

Is this the solution you've been searching for? The button always remains inside the input field.

*{
  margin:0;
  padding:0;
  box-sizing:border-box;
}

body{
 margin:3rem;
}
.parentContainer{
  position:relative;
  margin:2rem;
}
input[type="text"]{
  height:30px;
  width:100%;  
  padding-right:2rem;
}

button{
  position:absolute;
  top:0;
  right:0;
  height:30px;
  padding:.2rem;  
  background-color:transparent;
  cursor:pointer;
  border:0;
}
<div class="parentContainer">
  <input type="text" />
  <button>&#x1F50D;</button>
</div>

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

What is the proper way to utilize the ES6 import feature when using a symbolic path to reference the source file?

I am seeking a deeper understanding of the ES6 import function and could use some assistance. The Situation Imagine that I have a portion of code in my application that is frequently used, so I organize all of it into a folder for convenience. Now, in t ...

Is it possible to dynamically render css using Express.js?

I have a need to dynamically generate CSS with each request. For example, in my Express.js application, I've set up a route like this: /clients/:clientId/style.css When a matching request is received, I want to retrieve the Client from the reposito ...

What is the reason behind causing the overflow to become visible on the parent anchor when a child anchor is added?

I've been facing a puzzling issue for the past day. I am working on creating a website that resembles Windows 8, where each box represents a list item. The code is more complex than what I have shared here, but the problem seems to be isolated... &l ...

Differences in HTML animations can be seen when comparing Google Chrome to Microsoft Edge. Looking for a workaround for autoplay to ensure

My intro video animation is facing recording difficulties due to the autoplay policy in Google Chrome. It seems nearly impossible to capture it accurately. If only autoplay could function for an offline HTML file, my issue would be resolved. Unfortunately ...

Utilizing Boolean Operators in JavaScript with Thymeleaf: A Guide

When incorporating Boolean conditions in JavaScript with Thymeleaf using th:inline="javascript", an exception is thrown which appears as follows: org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 22; The entity name must immediately follow the ...

Unable to transmit JSON data through FETCH protocol

I have set up an API Service using node js on port 3001 and a web UI with REACT running on port 3000. My goal is to POST details in JSON format from the web page to the API. While I can successfully hit the API, the JSON data is not being received properly ...

What is the method for obtaining multiple indices on an Array?

Attempting to find multiple index positions in an Array for a Boolean value. Experimenting with while and for loops to iterate through more than one index position without success so far. Below is the code snippet: let jo = [1,2,3,4,5] let ji = [1,2,3] ...

The GET request on the Express route is malfunctioning, causing the Postman request to time out after getting stuck for some

My Express app seems to be experiencing some issues with the GET route. When making a request using Postman, the response gets stuck for a while before fetching. The GET route is properly set up with all necessary request parsers and the app initialized an ...

Vue Bootstrap Checkbox and <b-table> with <b-form-checkbox> components combine to provide a powerful and flexible user

I am currently implementing b-form-checkbox with b-table to fetch the selected module Ids. <b-table id="module-table" :items="list.modules" :fields="fields" :busy="isBusy"> <template slo ...

Building secure routes in Next.js using AWS access tokens

After saving the AWS access token in local storage, I attempted to create a higher order component. The goal was to check if the token is present or not in local storage, redirecting to the login page when it's missing. However, there seems to be an i ...

Issue with Ionic 2's infinite scroll not triggering method on second scroll attempt

I utilized the ion-tab element to showcase a page (inboxitem) which encompasses ion-list and makes use of ion-infinite-scroll. The following code snippet resides in inboxitem.html <ion-content class="inbox can-swipe-list"> <ion-list> ...

IE does not support hover effects

Having trouble with a hover effect that works in Chrome but not in MSIE. Are there any alternatives or fixes to make it work in MSIE? The hover/rollover effects I've tried all seem to have this issue in IE. normalize.css demo.css set2.css font- ...

Determine the daily volume of emails sent from the "no-reply email" address using the Nodemailer library

Our company currently utilizes Nodemailer for internal email communication. Lately, we have been encountering issues with exceeding our daily SMTP relays, resulting in some emails failing to send. To investigate further, I have been tasked with monitoring ...

Compare the selected values of radio buttons with an array and find matches

I have multiple radio button groups, where each selection in a group corresponds to predefined values in an array. For example, selecting option 1 in Group 1 will increment values A and B by 1, while selecting option 2 will increment B, C, and D. The goal ...

When the window is fully loaded, JavaScript executes

Can someone help me set up this script to start running when the page loads? I want the vat field to automatically show up if the company name has been entered. Thank you! //--></script> <script type="text/javascript>//-- $('.colorbox ...

A step-by-step guide on changing an image

Is it possible to change an image when the user clicks on a link to expand its content? <ul class="accor"> <li> Item 1 <img src="../plus.png"> <p> Lorem ipsum dolor sit amet</p> </li> </ul> $(' ...

Activate the dialog box exclusively after data has been submitted via the submit button on a form

My goal is to create a data saving functionality with a next button. After filling out the form, clicking on the next button triggers a popup dialog asking, "Do you want to submit your data?" To achieve this, I included the following code in my submit but ...

Using an iframe to access HTTP content from an HTTPS website

Currently, I am facing an issue with a page that contains an iframe loading an HTML template from an Amazon AWS S3 bucket. Within the iframe, my goal is to take the link of the parent window and add additional parameters. For example, let's say my pa ...

Save picture in localStorage

Hello, I am currently working on a page where I need to retrieve an image from a JSON file and store it locally. Below is the code I have been using: <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-1.10.1.min. ...

Send a JSON string directly to Google Cloud Storage without the need for a file upload

When I need to receive data in the form of a JSON string from an external source and then upload it directly to Google Cloud Storage without saving it as a local file first, is there a way to accomplish this task? Thank you. storage .bucket(bucketName) ...