响应式搜索框问题,需要帮助

时间:2015-11-12 23:13:31

标签: javascript jquery html css

目前,我使用PrestaShop,我想改变搜索框的宽度,但是,当我将搜索框的宽度更改为650px时,在桌面上它还可以,但在移动设备上搜索框非常好很久 - 根本没有回应。你能帮忙解决这个问题吗?



#search_block_top {
  padding-top: 30px;
  width: 650px;
}
#search_block_top #searchbox {
  float: left;
  width: 100%;
  margin-top: -20px;
}
#search_block_top .btn.button-search {
  background: #7ab55c;
  display: block;
  position: absolute;
  top: 0;
  right: 0;
  border: none;
  color: #fff;
  width: 80px;
  height: 40px;
  text-align: center;
  padding: 10px 0 11px 0;
}
#search_block_top .btn.button-search span {
  display: none;
}
#search_block_top .btn.button-search:before {
  content: "\f002";
  display: block;
  font-family: "FontAwesome";
  font-size: 17px;
  width: 100%;
  text-align: center;
}
#search_block_top .btn.button-search:hover {
  color: #6f6f6f;
}
#search_block_top #search_query_top {
  display: inline;
  padding: 13px 60px 13px 13px;
  height: 40px;
  background: #fbfbfb;
  margin-right: 1px;
}
.ac_results {
  background: #fff;
  border: 1px solid #d6d4d4;
  width: 271px;
  margin-top: -1px;
}
.ac_results li {
  padding: 0 10px;
  font-weight: normal;
  color: #686666;
  font-size: 13px;
  line-height: 22px;
}
.ac_results li.ac_odd {
  background: #fff;
}
.ac_results li:hover,
.ac_results li.ac_over {
  background: #fbfbfb;
}
form#searchbox {
  position: relative;
}
form#searchbox label {
  color: #333;
}
form#searchbox input#search_query_block {
  margin-right: 10px;
  max-width: 222px;
  margin-bottom: 10px;
  display: inline-block;
  float: left;
}
form#searchbox .button.button-small {
  float: left;
}
form#searchbox .button.button-small i {
  margin-right: 0;
}




enter image description here

2 个答案:

答案 0 :(得分:0)

尝试设置max-width

#search_block_top {
 padding-top: 30px;
 width: 100%;
 max-width: 650px;
}

答案 1 :(得分:0)

您可以使用媒体查询并编写类似的内容:

#search_block_top {
  padding-top: 30px;
  width: 650px;
  @media screen and (max-width: 650px) {
    width: 95%;
  }

}