简体   繁体   English

IE8和IE9之间的布局差异

[英]layout difference between IE8 and IE9

I have a site ( www.jamesalder.co.uk ) which is not rendering properly in IE8 and below. 我有一个网站( www.jamesalder.co.uk )在IE8及以下版本中无法正确呈现。

Here it is in IE8: 在IE8中: 在IE8中

And in IE9 and everything else: 在IE9和其他所有版本中: 在IE9中

As you can see, the search box has moved from top right to the wrong place. 如您所见,搜索框已从右上移到错误的位置。 The html for the search box is: 搜索框的html是:

<div id="header">
    <img src="/media/header_images/ts-hutton_2.jpg" title="Victorian Paintings at James Alder Fine Art" alt="Victorian Paintings at James Alder Fine Art" "="">
    <form id="search-form" action="/search">
             <label id="search-label">Search the Site</label>
             <input type="image" src="/static/images/sign-up.gif" value="search" id="search-button">
             <input type="text" name="q" id="search-input">
    </form>

</div>

It seems as though it is totally missing out the following CSS, in that if I disable this CSS, it has the same effect: 似乎完全遗漏了以下CSS,因为如果我禁用此CSS,它会产生相同的效果:

#search-form {
    position: absolute;
    right: 0;
    top: 0;
    background-color: rgba(255, 255, 255, 0.6);
    padding: 3px;
}

Does IE9 have some kind of problem with CSS on forms? IE9表单上的CSS是否存在某种问题? Should I put it in a div? 我应该放在div中吗?

As for the images below that which have decided not to float any more, I have no idea. 至于下面决定不再浮动的图像,我不知道。

Are there any best practices or good resources about getting sites to behave across older versions of IE, or should I just use conditionals? 是否有使网站在旧版IE上正常运行的最佳实践或良好资源,还是应该只使用条件接收?

It was actually caused by malformed html. 它实际上是由格式错误的html引起的。 I had tags which looked like this: 我有看起来像这样的标签:

<img src="/media/homepage_images/all-paintings-sale.jpg" 
     alt="All Victorian Paintings for Sale" 
     title="All Victorian Paintings for Sale" ">

Notice the " at the end, which was causing everything following it to be treated as text. Bizarrely, IE9 and everything else fixed the error automatically but IE8 and below didn't. 注意最后的“,这导致将其后的所有内容都视为文本。奇怪的是,IE9和其他所有内容都自动修复了错误,但IE8及以下版本没有解决。

It may cause by <form> . 这可能是由<form>引起的。

Put your <form id="search-form" action="/search"> element in a div. 将您的<form id="search-form" action="/search">元素放入div中。

<div id="header">
    <img src="..."/>
    <div id="search-form">
        <form action="/search"></form>
    </div>
</div>

Try this please. 请尝试这个。

Apply this Css for.... 将此CSS应用于...。

/* Css for ie 8 */

#search-form {
    position: absolute\0/;
    right: 0\0/;
    top: 0\0/;
    background-color: rgba(255, 255, 255, 0.6)\0/;
    padding: 3px\0/;
}

======================================================

/* Css for ie 9 */

:root #search-form {
    position: absolute\0/IE9;
    right: 0\0/IE9;
    top: 0\0/IE9;
    background-color: rgba(255, 255, 255, 0.6)\0/IE9;
    padding: 3px\0/IE9;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM