html - 我搜索的图片中的图片没有对齐

标签 html css

这是我的 link如果你看看我在顶部的搜索框,你会发现设计有点不对劲。

这是我的html

<form action="/contacts" class="myform" method="get">
    <div style="margin:0;padding:0;display:inline">
    <input name="utf8" type="hidden" value="&#x2713;" /></div>
    <fieldset style="border:none; padding-top:12px;">
    <ul><li>
    <input id="search_area" name="search" type="text" value="matt" />
    <span class="submit_form"></span>
    </li>
    </ul>
    </fieldset>      
</form>

这是我的一些 CSS

#search_bar {
    width: 265px;
}
#search_area {
    background-color:transparent;
    border:medium none;
    color:#000;
    font-size:15px;
    margin-left:10px;
    margin-top:7px;
}
.myform {
    margin: 0px;
    padding: 0px;
}

.submit_form{
    background-image: url(images/search_bar_mag.png);
    height: 35px;
    width: 38px;
    display: inline-block;
    position:relative;
    top:2px;
}
.submit_form:hover{
    background-image: url(images/search_bar_mag.png);
    background-position:bottom center;
}
.myform ul {
    margin: 0px;
    padding: 0px;
    display: block;
}
.myform li {
    background-image: url(images/search_bar_bg.png);
    height: 35px;
    width: 263px;
    display: block;
    font-size: 20px;
}
.myform li:hover {
    background-image: url(images/search_bar_bg.png);
    background-position:center -35px;
}

基本上我需要右边的图像作为表单的提交....关于为什么样式不对的任何想法

最佳答案

发现错误。

您正在与它后面的 共享一条线。 span 的高度是 35px,而 input 的高度只有 18。它们是垂直对齐的,所以 input 比它应该的低。从 css 规则 .submit_form 中删除高度属性,然后查看更改。

要解决此问题,请添加此样式代码:

span.submit_form {
  background-position: 0 -6px;
  height:20px !important;
}

关于html - 我搜索的图片中的图片没有对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7210054/

相关文章:

html - 如何将列内容放在底部?

html - 当有其他背景图像时,具有重复的背景图像必须停止

javascript - 删除内部div时正确调整外部div

asp.net - CSS媒体打印导致IE中打印时部分页面被截断

javascript - 按 Esc 按钮后恢复为原始 html

jquery - 放大 body 背景效果

html - 图像下方的颜色条出现

html - 有没有办法删除 div 但保留其元素?

html - 我可以在 div 中按像素使用文本对齐吗?

html - 是什么导致 IE/FF 折叠宽度 : 0 inline blocks inside tables but Chrome/Opera not to?