Search code examples
htmlcssfont-awesome-4

Why does clicking search icon do nothing?


For some reasons when I enter value in the search box and press the search icon, it does not hot enter . It happens only in FF. In chrome, if you press search icon, it works.

<div class="col-lg-12">
  <input id="query" name="query" type="search" class="form-control input-lg" value="">
  <button type="submit" class="submit"><i class="fa fa-search"></i></button>
</div>

Styles:

button.submit {
  border: 0px;
  box-sizing: initial;
  padding: 0px;
  margin: 0px;
}
.fa-search {
  position: absolute;
  top: 8px;
  right: 22px;
}

Any idea how to fix this? I mean is not the button supposed to be clickable when the icon search is pressed?


Solution

  • Firstly Do not use the <i> tag for icons it's use is for wrapping around text that has a different meaning from the text & is required to be in italic's. Use a <div> instead

    The main issue here is your CSS you have markup that is not treated well cross browser.

    You have your .fa-search icon set as position:absolute; but its wrapper has no definitions on positioning or height etc; so it wont wrap its child you should give position:absolute; to the button as the button is what your pressing not the icon.


    Remove the commented out styles from your class.

    .bor-header .bor-header-search .fa-search {
      /* top: 8px; */
      /* right: 22px; */
      color: #5D6161;
      font-size: 28px;
      /* position: absolute; */
    }
    .bor-header .bor-header-search button.submit {
      background-color: #FFF;
      border: 0px none;
      box-sizing: initial;
      padding: 0px;
      margin: 0px;
      top: 2px;
      color: #5D6161;
      font-size: 28px;
      position: absolute;
      width: 25px;
      right: 25px;
      height: 25px;
    }