IE8 中表单不响应的边距和填充

发布于 2025-01-06 03:45:08 字数 3580 浏览 3 评论 0原文

我们即将结束大规模的网站重新设计,所以我正在测试和检查跨浏览器等等。我对我的带有图像悬停的漂亮表单感到非常自豪,并在 IE8 中检查它,结果发现文本的填充和边距都弄乱了。

以下是显示问题的图像的链接:https://i.sstatic.net/80UZ6.jpg

这不是什么大问题,只是从设计师的角度来看非常烦人,可能对用户来说也是如此。

这是一个 jsfiddle 来查看表单的样子: http://jsfiddle.net/kennyk3/qL96P/

这是表单的 HTML/CSS:

<div id='account'>
            <form id='login' action='signin.php' method='post' accept-charset='UTF-8'>
            <fieldset class='topform'>
            <input type='hidden' name='submitted' id='submitted' value='1'/>
            <div id='front_login_text'>
            <label for='email'>Email:</label>                               
            <input type='text' name='email' id='email' class='textInput' maxlength='50' />
            <label for='password'>Password:</label>
            <input type='password' name='password' id='password' class='textInput' maxlength='50' />
            </div>
            <input type='submit' name='Submit' value='' class='loginsubmit' />
            <p class='remtext'><input type='checkbox' class='rememberme' name='remember' value='remember' />Remember me on this computer</p>
            <p class='notamember'><strong>Not a Member?</strong> <a href='/register.php'>Sign Up Today!</a></p>
            </fieldset>
            </form>
            <p class='forgotpw'>Forgot Your Password? <a href=''><strong>Click Here to Reset it.</strong></a></p>
            </div>
            <div class='break'></div>
            <div id='button'>
            <a href='' class='toursprite' title='Take the Tour'>Take the Tour</a>
            </div>



.topform    {
    padding: 60px 0 0 20px ;
    border: none;
}
.textInput
{
    width: 190px;
    height: 39px;
    background: url(../images/textfield-bg.png) no-repeat;
    border: none;
    color: #929292;
    padding: 0 20px 0 10px;
    margin: 5px 0 0 0;
    overflow: hidden;
}

.textInput:hover {
    background: url(../images/textfield-hover.png) no-repeat;

}
#account label {
    float: left;
    text-align: right;
    width: 60px;
    font-size: 14px;
    margin: 12px 10px 0 0;
    color: #929292;
}

#account fieldset {
    width: 300px;
}

#front_login_text input:focus, #front_login_text textarea:focus {
    outline: 0;
    background: url(../images/textfield-hover.png) no-repeat;
}

#side_login_text input:focus, #side_login_text textarea:focus {
    outline: 0;
    background: url(../images/textfield-hover-small.png) no-repeat;
}

#side_optin_text input:focus, #side_optin_text textarea:focus {
    outline: 0;
    background: url(../images/textfield-hover-small.png) no-repeat;
}

.loginsubmit {
    float: right;
    margin: 10px 5px 0 0;
    width: 70px;
    height: 35px;
    background: url(../images/login-btn.png) center no-repeat;
    border: 0 none;
    cursor: pointer;
}

.loginsubmit:hover {
    float: right;
    margin: 10px 5px 0 0;
    width: 70px;
    height: 35px;
    background: url(../images/login-btn-hover.png) center no-repeat;
    border: 0 none;
    cursor: pointer;
}

.loginsubmit:active {
    float: right;
    margin: 10px 5px 0 0;
    width: 70px;
    height: 35px;
    background: url(../images/login-btn-active.png) center no-repeat;
    border: 0 none;
    cursor: pointer;
}

We're coming to the end of a huge site redesign, so I'm testing and checking, cross-browser and all that. I was so proud of my beautiful forms with image hovering and checked it in IE8 only to see that the padding and margin for the text was all messed up.

Here's a link to an image displaying the problem: https://i.sstatic.net/80UZ6.jpg

It's not a huge deal, just extremely annoying from a designer's point of view and probably the user's too.

Here's a jsfiddle to see what the form looks like: http://jsfiddle.net/kennyk3/qL96P/

And here's the HTML/CSS for the form:

<div id='account'>
            <form id='login' action='signin.php' method='post' accept-charset='UTF-8'>
            <fieldset class='topform'>
            <input type='hidden' name='submitted' id='submitted' value='1'/>
            <div id='front_login_text'>
            <label for='email'>Email:</label>                               
            <input type='text' name='email' id='email' class='textInput' maxlength='50' />
            <label for='password'>Password:</label>
            <input type='password' name='password' id='password' class='textInput' maxlength='50' />
            </div>
            <input type='submit' name='Submit' value='' class='loginsubmit' />
            <p class='remtext'><input type='checkbox' class='rememberme' name='remember' value='remember' />Remember me on this computer</p>
            <p class='notamember'><strong>Not a Member?</strong> <a href='/register.php'>Sign Up Today!</a></p>
            </fieldset>
            </form>
            <p class='forgotpw'>Forgot Your Password? <a href=''><strong>Click Here to Reset it.</strong></a></p>
            </div>
            <div class='break'></div>
            <div id='button'>
            <a href='' class='toursprite' title='Take the Tour'>Take the Tour</a>
            </div>



.topform    {
    padding: 60px 0 0 20px ;
    border: none;
}
.textInput
{
    width: 190px;
    height: 39px;
    background: url(../images/textfield-bg.png) no-repeat;
    border: none;
    color: #929292;
    padding: 0 20px 0 10px;
    margin: 5px 0 0 0;
    overflow: hidden;
}

.textInput:hover {
    background: url(../images/textfield-hover.png) no-repeat;

}
#account label {
    float: left;
    text-align: right;
    width: 60px;
    font-size: 14px;
    margin: 12px 10px 0 0;
    color: #929292;
}

#account fieldset {
    width: 300px;
}

#front_login_text input:focus, #front_login_text textarea:focus {
    outline: 0;
    background: url(../images/textfield-hover.png) no-repeat;
}

#side_login_text input:focus, #side_login_text textarea:focus {
    outline: 0;
    background: url(../images/textfield-hover-small.png) no-repeat;
}

#side_optin_text input:focus, #side_optin_text textarea:focus {
    outline: 0;
    background: url(../images/textfield-hover-small.png) no-repeat;
}

.loginsubmit {
    float: right;
    margin: 10px 5px 0 0;
    width: 70px;
    height: 35px;
    background: url(../images/login-btn.png) center no-repeat;
    border: 0 none;
    cursor: pointer;
}

.loginsubmit:hover {
    float: right;
    margin: 10px 5px 0 0;
    width: 70px;
    height: 35px;
    background: url(../images/login-btn-hover.png) center no-repeat;
    border: 0 none;
    cursor: pointer;
}

.loginsubmit:active {
    float: right;
    margin: 10px 5px 0 0;
    width: 70px;
    height: 35px;
    background: url(../images/login-btn-active.png) center no-repeat;
    border: 0 none;
    cursor: pointer;
}

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

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

发布评论

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

评论(3

情徒 2025-01-13 03:45:08

处理跨浏览器兼容的表单时。确保您定义了字段的行高。它可以改变一切,并可能解决你的不一致之处。

When dealing with cross browser compatible forms. Make sure you define line-height for the fields. It can make all the difference and may fix your inconsistencies.

寻找一个思念的角度 2025-01-13 03:45:08

如果将行高设置为 200% 或 250% 之类的值,则 Chrome 中的行高仍应显示在中心,而 IE 中的行高应更接近中心。我刚刚在你的表格上试过了。

它不像浏览器特定的 CSS 修复那么干净,但它可能会满足您的需求。

.textInput
{
    width: 190px;
    height: 39px;
    background: url(http://i.imgur.com/sEdWU.png) no-repeat;
    border: none;
    color: #929292;
    padding: 0px 20px 0 10px;
    margin: 5px 0 0 0;
    overflow: hidden;
line-height:220%;   
}

If you set the line-height to be something like 200% or 250%, it should still display in the center for Chrome and in IE should be much closer to the center. I just tried it on your forms.

It's not as clean as a browser specific CSS fix, but it might serve your needs.

.textInput
{
    width: 190px;
    height: 39px;
    background: url(http://i.imgur.com/sEdWU.png) no-repeat;
    border: none;
    color: #929292;
    padding: 0px 20px 0 10px;
    margin: 5px 0 0 0;
    overflow: hidden;
line-height:220%;   
}
情话难免假 2025-01-13 03:45:08

IE8 读取边距很有趣,有时还会折叠它们。这个 CSS hack 不是重做任何事情:

.textInput
{
    width: 190px;
    height: 39px;
    background: url(http://i.imgur.com/sEdWU.png) no-repeat;
    border: none;
    color: #929292;
    padding: 0 20px 0 10px;
    margin: 5px 0 0 0;
    padding: 10px 20px 0 10px\9;
    overflow: hidden;
}

IE8 reads margins funny and sometimes collapses them. Rather than redoing anything do this CSS hack:

.textInput
{
    width: 190px;
    height: 39px;
    background: url(http://i.imgur.com/sEdWU.png) no-repeat;
    border: none;
    color: #929292;
    padding: 0 20px 0 10px;
    margin: 5px 0 0 0;
    padding: 10px 20px 0 10px\9;
    overflow: hidden;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文