Is it possible to create an input box that automatically adjusts its size with rounded corners

I designed a text-box resembling the image shown below, but I am trying to make it resize as the user types similar to this example: http://jsbin.com/ahaxe

Although I believe inserting the search image as a background and aligning it to the right will not be an issue, I am uncertain about how to achieve rounded corners without relying on an image.

Appreciate everyone's help :)

Answer №1

input {
  -webkit-border-radius: 12px; /* Supported by Safari and iOS versions below 3.2 */
     -moz-border-radius: 12px; /* Compatible with Firefox versions 1 to 3.6 */
          border-radius: 12px; /* Works on Opera 10.5, Internet Explorer 9, Safari 5, Chrome, Firefox 4, iOS 4, Android 2.1+ */
} 

Answer №2

It is feasible, however, it may not function properly in Internet Explorer. To achieve this effect, you can utilize CSS styles. For instance: -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px;

Answer №3

Start by testing faraz's suggestion, and if it doesn't work in IE, consider adding another declaration using the -ms- prefix:

-ms-border-radius: 12px;

If that doesn't solve the issue, you can attempt using CSS PIE to enforce CSS3 on IE:

For the resize solution, there may be better alternatives out there, but you can give this a try:

<input onkeyup="if(this.value.length > 10) { this.style.width = this.offsetWidth + 20 + 'px' }" type="text" />

In this code, the JavaScript will increase the width of the input box by 20px every time the user types something and the character count exceeds 10.

Feel free to customize the values as needed and best of luck with your project.

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

Troubleshooting Problem with Website Responsiveness on iPhones Using Bootstrap 5

I am currently experiencing a challenge involving the responsiveness of a website I am developing, particularly when it comes to iPhones. The site utilizes Bootstrap 5 and displays correctly on Android devices and in Chrome Dev Tools. However, upon testing ...

What is the best way to assign an array from a text input field to a JavaScript variable?

How can I input an array like [1, 2, 3] into a text input on an HTML page and then apply it to the var array in a function named inputArray() when a button is clicked? I attempted to do this with: var array=document.querySelector("#inputNumber" ...

ESP32 - Creating a dynamic webpage using a webserver

I am using an ESP32 configured as a webserver. I have multiple webpages that are included as files, such as index.h const char MAIN_page[] PROGMEM = R"=====( <!DOCTYPE html> <html> some divs here.... </html> )====="; The conten ...

What benefits does a dynamic website like this offer compared to one that is purely AJAX-based?

There are two main categories of dynamic websites that I define: The first type utilizes languages like PHP to concatenate an HTML page and send it back to clients. On the other hand, the second type uses an HTML template where all interfaces provide JSO ...

How can I toggle the visibility of stacked divs using jquery?

I am trying to create a specific effect with two divs. The goal is to display them one after the other, with the first fading in, then fading out, followed by the second div fading in and then fading out. $('[class^="flash"]').each(function(inde ...

Angular - The differ is unable to find support for the object 'Item One' which is of type 'string'. NgFor is only able to bind to Iterables like Arrays and not individual objects

Many questions on StackOverflow share similarities with this one, but I have not been able to find a solution that fits my issue. My code functions correctly when attempting to populate items in a "Select" control. It successfully retrieves data if the it ...

After the successful completion of the AJAX request, I aim to transmit the identification data via the

Click here for image preview Below is the table content: Using jQuery: <script type="text/javascript> $(document).ready(function(){ $(document).on('keydown','#search',function(){ var input = $(this).val(); ...

The collapsible toggle menu fails to collapse on mobile-sized screens

I've experimented with basic Bootstrap in order to create a toggle menu, but I'm encountering issues. The menu collapses instead of expanding when the screen size is maximized ('m'). Furthermore, clicking on the toggle icon does not cau ...

I am facing an issue with my ajax call where it only works once, and I need to refresh the page for it

I'm currently working on implementing a form with Ajax functionality. Below is the HTML portion where I am trying to input: <form class="col s12"> <div class="row"> <div class="input-field col s6"> ...

PHPBB authentication system

After experimenting with the script based on the guidance I received from you all, I've encountered another issue. When I click 'login' on the login form, it displays this message: The page isn't redirecting properly. Firefox has detect ...

Is there a way to use the <form> element with the specified action attribute and a <button> element of type submit to create a button that functions as a hyperlink?

Here is my approach to creating stylish buttons. <span class='button button-orange' id='sign-up'><input type='button' value='Sign up here' /></span> When adding an anchor tag (with href) around th ...

Displaying a Javascript popup table with the press of F1 key and disabling Chrome's built-in Help page

In my ASP.Net Web Application, I have implemented a JavaScript popup Table named Aview2. The goal is to display this popup table when the F1 button is pressed in the TxtItemCode field. However, whenever I try to show the popup table using the F1 key, it di ...

Using the preg_match_all function in PHP with multiple wildcards

Is there a way to extract a number from HTML that is between <td>...</td>? I attempted to use the code below: $views = "/<td id=\"adv-result-views-(?:.*)\" class=\"spec\">(.*?)<\/td>/"; The numbers that co ...

mentioning a JSON key that includes a period

How can I reference a specific field from the JSON data in Angular? { "elements": [ { "LCSSEASON.IDA2A2": "351453", "LCSSEASON.BRANCHIDITERATIONINFO": "335697" }, { "LCSSEASON.IDA2A2": "353995", "LCSSEASON.BRANCHIDITER ...

How can I float a square to the right in Bootstrap with a col-md-4 size but with a height restricted to only 200 px

Looking to add a small square on the page for users to search and purchase courses directly. The square should be 4 columns wide, follow Bootstrap4 grid template, and be around 200-300 px in length. It needs to remain visible as the user scrolls down the p ...

Collection of numbers with decimal points

Can one use <li> numbers in this format?: 1.1 First Item 1.2 Second Item 2.1 Other item ...

My website crashed after attempting to update WordPress

After upgrading my website to Wordpress 3.4, I encountered a major issue that caused significant damage to my site. It seems that half of my posts were not accessible and resulted in a 404 error. Additionally, pages 3 and 4 of my posts also showed a 404 er ...

Adjust dimensions of images in Bee3D carousel

I recently utilized the Bee3d library available on the following Github link: https://github.com/lukeed/bee3d While I found everything to be truly impressive, I am curious if there is a way to adjust the image size. Whenever I attempt to change the image ...

Leveraging the power of jQuery and Bootstrap within an application customizer and across various web

Deciding to utilize Bootstrap for customization is a personal choice of mine. Currently, I am considering incorporating jQuery and Bootstrap in both the application customizer and multiple web parts. I am seeking advice on the most effective approach for ...

Is your overlaying div functioning properly in Chrome and Firefox, but encountering issues in Internet Explorer?

I am facing a challenge with overlaying two divs on top of an image. My objective is to create a simple lightbox where when the user hovers over the left or right side, the cursor changes to a pointer and arrows appear. Below is the code I am using: HTML: ...