IE8负边距问题

发布于 2024-11-13 10:47:36 字数 2068 浏览 1 评论 0原文

我在 IE8 中遇到布局问题,只有负边距会造成奇怪的事情。

我尝试使用在该论坛中找到的一些修复程序,但无济于事。毕竟是周五晚上啊!

页面位于:http://community.thelandtrust.org.uk/wordpress/

罪魁祸首是右侧的搜索字段,它有一个负边距,允许按钮位于同一行上。

除了 IE8 之外,它在所有浏览器中都运行良好。在 IE8 中,右侧边距为 -80px,按钮位于该字段上方,但右侧有很大的空间。右边距为 -40px 时,按钮位于下一行,并且右侧仍然有很大的空间。

我注意到每次它与右侧的距离似乎都是相同的。是清算的问题吗?

预先感谢您提供的任何帮助!

代码:

<form action="http://community.thelandtrust.org.uk/wordpress/" id="search-form" class="search-form" method="get">
    <div>
        <input type="text" onblur="if(this.value=='')this.value=this.defaultValue;" onfocus="if(this.value==this.defaultValue)this.value='';" value="Search..." id="search-text" name="s" class="search-text">
        <input type="submit" value="Go" id="search-submit" name="submit" class="search-submit button">
    </div>
</form>

CSS:

input,textarea {
    background:#f7f9e0 url(images/Input_gradient.jpg) repeat-x top left;
    border:none;
    -moz-border-radius:20px;
    border-radius:20px;
    vertical-align:middle;
    min-height:20px;
    width:94%;
    font-family:Arial, sans-serif;
    font-size:1em;
    padding:10px 20px;
}
input.button,input#submit {
    background:#e6e99d url(images/Button_gradient.jpg) repeat-x bottom left;
    height:40px;
    width:auto;
    min-width:40px;
    font-weight:700;
    cursor:pointer;
    float:right;
}
input.button:hover,input#submit:hover,#primary-menu li a:hover {
    background:#c7cc5c;
}
form#search-form{
    overflow: hidden;
}
input.search-text {
    margin-right: -80px;
    width: 200px;
    float:left;
    font-size: 1.2em;
}
input.search-submit {
    background:url(images/Button_arrow_40px.png) no-repeat 0 0 transparent!important;
    width:40px;
    text-indent:-1000px;
    font-size: 0;  
    display:block; 
    line-height: 0;
    float:right;
    clear:right;
}
input.search-submit:hover {
    background-position:0 -40px!important;
}

I have a layout issue in IE8 only where a negative margin does strange things.

I have tried to use some of the fixes I have found in this forum, but to no avail. It is Friday night after all!

The page is here: http://community.thelandtrust.org.uk/wordpress/

The culprit is the search field on the right hand side, which has a negative margin to allow the button to sit over it on the same line.

It works fine in all but IE8. In IE8, with a right margin of -80px the button is over the field but there is a large space to the right. With a right margin of -40px the button is on the next line, and still with a large space to the right.

I have noticed that it seems to be the same distance from the right each time. Is it a clearing issue?

Thanks in advance for any help you can offer!

The code:

<form action="http://community.thelandtrust.org.uk/wordpress/" id="search-form" class="search-form" method="get">
    <div>
        <input type="text" onblur="if(this.value=='')this.value=this.defaultValue;" onfocus="if(this.value==this.defaultValue)this.value='';" value="Search..." id="search-text" name="s" class="search-text">
        <input type="submit" value="Go" id="search-submit" name="submit" class="search-submit button">
    </div>
</form>

The CSS:

input,textarea {
    background:#f7f9e0 url(images/Input_gradient.jpg) repeat-x top left;
    border:none;
    -moz-border-radius:20px;
    border-radius:20px;
    vertical-align:middle;
    min-height:20px;
    width:94%;
    font-family:Arial, sans-serif;
    font-size:1em;
    padding:10px 20px;
}
input.button,input#submit {
    background:#e6e99d url(images/Button_gradient.jpg) repeat-x bottom left;
    height:40px;
    width:auto;
    min-width:40px;
    font-weight:700;
    cursor:pointer;
    float:right;
}
input.button:hover,input#submit:hover,#primary-menu li a:hover {
    background:#c7cc5c;
}
form#search-form{
    overflow: hidden;
}
input.search-text {
    margin-right: -80px;
    width: 200px;
    float:left;
    font-size: 1.2em;
}
input.search-submit {
    background:url(images/Button_arrow_40px.png) no-repeat 0 0 transparent!important;
    width:40px;
    text-indent:-1000px;
    font-size: 0;  
    display:block; 
    line-height: 0;
    float:right;
    clear:right;
}
input.search-submit:hover {
    background-position:0 -40px!important;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恬淡成诗 2024-11-20 10:47:36

由于某种原因 IE8 使按钮双倍宽度。

添加 padding: 0;input.search-submit 似乎可以修复它

for some reason IE8 is making the button double width.

adding padding: 0; to input.search-submit seems to fix it

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文