gpt-3.5-turbo-0613· openai
Suzhen/CodeChat
responsive input box type with submit using html and css
- User
responsive input box type with submit using html and css
- Assistant
To create a responsive input box type with a submit button using HTML and CSS, you can use the following code:
HTML:
<div class="form-container"> <form> <input type="text" placeholder="Enter your input" required> <button type="submit">Submit</button> </form> </div>CSS:
.form-container { display: flex; justify-content: center; align-items: center; height: 100vh; } form { display: flex; justify-content: center; align-items: center; } input[type="text"] { padding: 10px; border: none; border-radius: 4px 0 0 4px; outline: none; width: 250px; } button[type="submit"] { padding: 10px 20px; background-color: #4CAF50; border: none; border-radius: 0 4px 4px 0; color: white; cursor: pointer; } @media screen and (max-width: 600px) { input[type="text"] { width: 100%; } }In this example, we have used flexbox to center the form vertically and horizontally within the
.form-container. Theinputfield has a width of 250px by default and expands to 100% width on screens with a maximum width of 600px, making it responsive. The is styled with a green background color and white text, and it has some padding for better visual appearance.