Adjusting the width of the search bar in a Bootstrap inline form

Issue: The search box is not resizing with the page and I can't figure out how to make it wider. Adding styles like width: 100%; hasn't worked so far.

In addition, the select dropdown box in the image linked below appears slightly clipped on the right side. I'm unsure of the cause and how to fix it.

I also need assistance with making the form fill the width of the row. Any help would be greatly appreciated. Thank you!

Image of Form

Desired Layout

Code:

<header>
      <div class="container">
        <form action="search.php" method="get" data-toggle="validator" role="form" class="form-inline">
          <div class="row">
            <h2>Enter a username and choose a category to search in</h2>
              <div class="input-group">
                <div class="form-group">
                  <input name="search" type="text" class="form-control" aria-label="..." placeholder="Search a username here" required>
                </div>
              </div>
              <div class="input-group">
                <div class="form-group">
                  <select class="selectpicker form-control" required>
                    <option value="">Category</option>
                    <option value="volvo">Minecraft username</option>
                    <option value="saab">Minecraft UUID</option>
                    <option value="mercedes">Mc-Market username</option>
                    <option value="audi">Skype username</option>
                  </select>
                  <button type="submit" class="btn btn-default">Search</button>
                </div><!-- /form-group -->
              </div><!-- /input-group -->
          </div>  <!-- /row-group -->
        </form><!-- /form-group -->
      </div><!-- /container-group -->
    </header>

Answer №1

Avoid Mixing Components Together

It is important not to mix form groups or grid column classes directly with input groups. Instead, make sure to nest the input group inside of the form group or grid-related element.

For more information, visit the input-groups documentation. Ensure that your Input-groups are nested within form-groups and that the button markup is correctly placed within

<span class="input-group-btn">
.

Please Note: according to the documentation,

Avoid using <select> elements here as they cannot be fully styled in WebKit browsers.

Check out this Working Example: Open it using FullPage

header {
  background-color: #42f4c2;
  padding: 100px 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<header>
  <div class="container text-center">

    <h2>Enter a username and choose a category to search in</h2>

    <form action="search.php" method="get" data-toggle="validator" role="form" class="form-inline">

      <div class="form-group">
        <input name="search" type="text" class="form-control" aria-label="..." placeholder="Search a username here" required>
      </div>

      <div class="form-group">
        <div class="input-group">
          <select class="selectpicker form-control" required>
            <option value="">Catagory</option>
            <option value="volvo">Minecraft username</option>
            <option value="saab">Minecraft UUID</option>
            <option value="mercedes">Mc-Market username</option>
            <option value="audi">Skype username</option>
          </select>
          <span class="input-group-btn">
          <button type="submit" class="btn btn-default btn-search">Search</button>
          </span>
        </div>
      </div>

    </form>
  </div>
</header>

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

Is setting cache: 'no-store' in a fetch request enough to mimic client-side rendering behavior in Next.js?

Currently, I am working with Next.js and utilizing the fetch method to retrieve data: const res = await fetch(`${process.env.url}/test`, { cache: 'no-store', }) My understanding is that specifying cache: 'no-store' will trigger a fre ...

Having trouble establishing a connection between Atlas and Node.js

Here is the content of my server.js file: const express = require('express'); const cors = require('cors'); const mongoose = require('mongoose'); require('dotenv').config(); const app = express(); const port = pro ...

The input field is not displaying the characters I type, despite having a predefined state value in the value attribute

When I input text, it doesn't appear as I type even though I have set the value attribute and it is a controlled input. I've tested this on Stackblitz. My showText useState is set to an empty string. If I change it to just black, I can see the in ...

The font-weight property appears to be ineffective across all browsers

I'm struggling with the font-weight property in my CSS. Despite trying different values like lighter, bold, and even numerical values like 300, it doesn't seem to have any effect on the font weight in any browser. I am using the following code to ...

The text in Three.js fails to display

Hey there, I'm relatively new to Three.js and having some trouble getting basic text to render. Most of the solutions I found on StackOverflow seem outdated, so I thought I'd ask here. The code snippet below only results in a black screen. Any he ...

The jquery scrolltop() function provides the value of the scroll position prior to the current

Using the jQuery function element.scrollTop(), I attempted to retrieve the current scroll position of the page with the following line of code: var currentScrollPosition = $('html').scrollTop() || $('body').scrollTop(); However, this ...

How about designing a menu that changes based on user interaction?

After searching extensively on Stack Overflow and Google, I still haven't found the answer I'm looking for, so please don't be mad at me! :) On an HTML page utilizing ASP .NET 4.5, what type should I use for a link menu? I want to create a ...

Circular icons function as if they were squares

I'm currently working on designing a card using Bootstrap that includes some social media icons from Font Awesome. However, I've encountered an issue where all the icons are displaying as boxes with black outlines around them. Additionally, the h ...

Combining arrays using checkboxes in React.js

As someone completely new to coding, my current endeavor involves learning React by developing a flashcard app for studying Japanese. The concept revolves around incorporating a series of checkboxes that facilitate the selection of either Hiragana or Kat ...

Passing the value selected from a datepicker to PHP without refreshing the page through the use of XMLHttpRequest: Guide

Is it possible to transfer the datepicker value to PHP without reloading the HTML page by using XMLHttpRequest()? The intention is to utilize this date value for a subsequent query and present it on the same HTML page. <input type="date" id="month" o ...

How can I incorporate a string variable into an f-string in Python for printing?

Looking to display the user variable from a Python script in an HTML document? Here's a method to achieve this. my_python.py user = "myname" with open("../../html/forms/output.html") as output: print(output.readlines()) outpu ...

Halt of dispatcher playback occurs after a duration of 10 minutes with discord.js

Currently, I've been working on a music bot using discord.js. To handle audio streaming, I'm utilizing @discordjs/opus and ytdl-core-discord. Everything runs smoothly when testing the bot locally on my machine - songs from YouTube are played with ...

Express JS sub child routes are experiencing issues with static files not functioning properly

I used express-generator to create my project structure. In app.js, the code is as follows: var createError = require('http-errors'); var express = require('express'); var path = require('path'); var cookieParser = require(&a ...

Is it possible to generate objects dynamically as the program is running?

Looking at the code snippet below, I currently have an array containing two JSON objects. However, if I need to create 20 objects, is there a more efficient way than manually writing each object in the array? Furthermore, is it possible to generate these o ...

Generating dynamic dropdown menus using data from a database with the help of PHP and Ajax technologies

I'm currently working on creating a dynamic dropdown menu that will be populated with data retrieved from a database. I've hit a roadblock in parsing the data from a multidimensional array sent by a PHP file. Here's a snippet of my code: Se ...

How can I adjust the width of each <li> element in a JQuery Slider?

Please note: I have read several related posts on Stack Overflow and they did not address my specific issue. The Issue In my slider panel, there is an unordered list with varying numbers of <li> elements that have different widths. Each li contains ...

If an array is present in the object, retrieve the array item; otherwise, retrieve the field

When obj arrays are nested and found, everything works correctly; however, if they are not found, the page breaks as it becomes null. How can I check if they exist beforehand, and if not, just output the next level field? The code below works when both ar ...

After changing the page, the Facebook JS SDK fails to function properly when using JQueryMobile

I'm facing an issue with my webapp that utilizes jQuery Mobile for full ajax navigation. I have initialized the Facebook SDK at the pageinit event in jQueryMobile (called on each page). jQuery(document).on('pageinit', function (event) { ...

Guide on uploading files and data simultaneously by leveraging ajax, jquery, and spring mvc

How can I use ajax, query, and Spring MVC to upload data along with a file? Below is my modal pop-up, could someone help me with this? <!-- Modal --> <div id="fileUpload" class="modal fade" role="dialog"> <d ...

The delay in executing JQuery show() can be observed on Internet Explorer and Chrome browsers

I have a div overlay that displays "processing..." using $('').show() before initiating ajax calls and then hides upon completion. The issue I am facing is that in Internet Explorer (7) and Chrome (2.0.172.39), if I try to display the div, make m ...