【问题标题】:background color on search glyphicon搜索字形图标的背景颜色
【发布时间】:2018-02-22 10:42:03
【问题描述】:

我正在尝试让我的搜索字形上的背景颜色占据整个框。理想情况下,它应该看起来像 this

但是,它目前看起来像this

我不确定发生了什么。

这是我的 html(我正在使用 Bootstrap)。

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-md-6">
  <div id="custom-search-input">
    <div class="input-group col-md-12">
      <input type="text" class="form-control input-lg" placeholder="Search by user name, member types, genres..." />
      <span class="input-group-btn">
        <button class="btn btn-info btn-lg" type="button">
          <i class="glyphicon glyphicon-search"></i>
        </button>
      </span>
    </div>
  </div>
</div>

编辑添加我的 CSS:

#custom-search-input{
    padding: 3px;
    border: solid 1px #E4E4E4;
    border-radius: 6px;
    background-color: #fff;
    height: 75%;
}

#custom-search-input input{
    border: 0;
    box-shadow: none;
}

.input-group-btn{
    background: #E44424;
}

#custom-search-input button{
    margin: 2px 0 0 0;
    background: #E44424;
    box-shadow: none;
    border: 0;
    color: black;
    padding: 0 8px 0 10px;
    border-left: solid 1px #ccc;
}

#custom-search-input button:hover{
    border: 0;
    box-shadow: none;
    border-left: solid 1px #ccc;
}

#custom-search-input .glyphicon-search{
    font-size: 23px;
}

【问题讨论】:

  • 您需要使用单独的类将 bg 颜色应用于 .input-group-btn
  • 请附上您的 CSS,谢谢
  • #custom-search-input{ padding: 3px;边框:实心 1px #E4E4E4;边框半径:6px;背景颜色:#fff;身高:75%; } #custom-search-input 输入{边框:0;盒子阴影:无; } #custom-search-input 按钮{ 边距:2px 0 0 0;背景:#E44424;盒子阴影:无;边框:0;颜色:黑色;填充:0 8px 0 10px;左边框:实心 1px #ccc; } #custom-search-input 按钮:悬停{边框:0;盒子阴影:无;左边框:实心 1px #ccc; }

标签: html css search bootstrap-4


【解决方案1】:

你有填充

    #custom-search-input{ 
       padding: 3px; 
    }

这就是原因。 你应该把它放在

    .form-control{
    padding: 3px; 
    }

如果您需要对输入进行填充

Here's Plunker

【讨论】:

  • 谢谢,米奇。我输入了你的代码,但它看起来仍然很不稳定。背景颜色周围仍然有一片白色。
  • 可以分享截图吗?
  • 我用新图片更新了原始帖子。更改了颜色,但您仍然可以在镜框的蓝色后面看到一丝白色。
  • 罪魁祸首是“border:solid 1px #E4E4E4;”。删除它。
  • 好多了。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-10-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多