【发布时间】:2016-10-29 05:15:43
【问题描述】:
我想在 input-group 中使用自定义图像,而不是 Bootstrap 字形图标没有底部填充(我的图像触摸按钮的底部),正如您在这张图片中看到的那样:
其实我用的是Bootstrap的glyphicon glyphicon-search:
<div class="input-group">
<input type="text" class="form-control" placeholder="Rechercher un produit, une référence ..."/>
<span class="input-group-addon">
<span aria-hidden="true" class="glyphicon glyphicon-search"></span>
<span class="hidden-xs text-upper-style">
Rechercher</span>
</span>
</div>
我的问题是我无法在搜索栏中用我的图片替换 glyphicon。
我尝试创建 CSS 来模仿 Bootstrap 的那些,但它总是呈现糟糕:
CSS
.glyphi {
position: relative;
top: 1px;
display: inline-block;
font-style: normal;
font-weight: normal;
line-height: 1;
float: left;
display: block;
}
.glyphi.search {
background: url(../img/header/search.png);
background-size: cover;
}
.glyphi.normal {
width: 28px; //But Bootstrap glyphicon is 16x16...
height: 16px;
}
HTML
<span class="glyphicon glyphicon-search"></span>
请注意,我的图片不是正方形(60x37 像素)。
这是应该替换glyphicon的图片:
最好的 Bootstrap 方法是什么? Here is a Bootply 我的代码。
谢谢! :)
【问题讨论】:
-
您不想对 HTML 进行任何更改?
-
您可以根据需要更改 HTML,它应该像我的图片一样呈现,并且具有响应性(在小屏幕上呈现良好):-)
标签: css twitter-bootstrap twitter-bootstrap-3 responsive-design