CSS- Changing the width of a search box

tadm123 picture tadm123 · Mar 10, 2017 · Viewed 11.2k times · Source

I'd been trying to change the width of the search box in name="size" of my HTML template but can't do it even when I tried width:.

html:

<form class="form" method = "POST" >

        <h1>Soccer Shoes Finder</h1>
        <div class="line-separator"></div>

            <div class="container-fluid form-inline">

                <input class="form-control" name = "name" type="text" placeholder="Name"/>
                <input class="form-control" name = "size" type="text" placeholder="Size"/>
                <button class="form-control fa fa-search" aria-hidden="true"></button>
            </div>

</form>

css of the element:

input[name="size"]{
  width: 50%;
}

Here's a codepen for better context:

http://codepen.io/tadm123/pen/ZLVWpd

Answer

Aslam picture Aslam · Mar 10, 2017

I recommend using this method.

<form class="form" method="POST">

  <h1 class="text-center">Soccer Shoes Finder</h1>
  <div class="line-separator"></div>

  <div class="container ">

    <div class="row">
      <div class="col-md-4">
        <input class="form-control" name="name" type="text" placeholder="Name" />
      </div>
      <div class="col-md-7">

        <input class="form-control" name="size" type="text" placeholder="Size" /></div>

      <div class="col-md-1">
        <button class="form-control " aria-hidden="true"><i class="fa fa-search"></i></button></div>
    </div>

  </div>

</form>

Updated Codepen: http://codepen.io/hunzaboy/pen/aJJpMK