【发布时间】:2012-08-21 01:44:55
【问题描述】:
我正在使用 float: left;和浮动:对;将两个 div 容器排成一行,左边一个是输入栏,右边是一个小背景图片(搜索按钮)。
它在 Opera 和 Firefox、MSIE 9.0+ 中显示良好,但是当我在 chrome 中查看它时,右侧容器的背景图像稍微偏离了位置(向下移动了几个像素)。
我将背景颜色设置为红色以突出显示问题: screenshot
index.php 取出:
<div class="header_inner_right">
<form id="search_bar" method="post" action="" onsubmit="return checkSearchQuery();">
<div class="left">
<input id="search_field" name="q" type="text" value="Search riddim, artist, tune, label and producer"
onfocus="searchFieldValue_onFocus();" onblur="searchFieldValue_onBlur();">
</div>
<div class="right">
<input id="search_button" src="images/search_button.gif" type="submit" value="">
</div>
</form>
</div>
index_chrome.css(当 php 脚本检测到 chrome 浏览器时使用):
@charset "ISO-8859-1";
#search_bar {
width: 450px;
height: 37px;
background-color: red
}
#search_bar #search_field {
border: 0px;
width: 365px;
height: 37px;
padding-left: 20px;
padding-right: 20px;
background-image: url(../images/search_field.gif);
background-repeat: no-repeat;
font-weight: bold;
color: #c0c0c0;
background-color: #ffffff
}
#search_bar #search_button {
cursor: pointer;
border: 0px;
outline: none;
height: 37px;
width: 45px;
background-image: url(../images/search_button.gif);
background-repeat: no-repeat
}
如何修复并调整放大镜背景图像的y位置,使其与左侧div的背景图像完美对齐并完全隐藏右侧div容器的红色背景?
抱歉,忘记了 JSFiddle!
【问题讨论】:
-
你能提供一个jsfiddle 适当的资源,以便我们可以在我们的机器上编辑它吗?
-
您可以使用
display:inline-blockcss 将您的 div 放在一行中。 -
刚刚添加了JSFiddle链接,对这个问题很好奇,但可能只是因为我缺乏跨浏览器css的经验。
标签: html css image google-chrome background