<身体GT;位置:相对,内嵌VS.css文件(IE7) [英] <body> position: relative, inline VS .css-file (IE7)

查看:129
本文介绍了<身体GT;位置:相对,内嵌VS.css文件(IE7)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IE7中遇到了一些非常奇怪的行为。我想定位< body> -tag relative。



如果我输入

  body {position:relative; }我的css文件中,我的菜单(这是位置:绝对)无法正常工作。} 

但如果我使用

 < body style =position:relative;> 

有效。这怎么可能有所作为?没有JavaScript是删除CSS属性或类似的东西。

解决方案

对此很好奇,但正如问题所展示的@ thirtydot的评论似乎是正确的:答案是没有区别。我创建了这个jsfiddle ,它在IE7中按照预期呈现(完全诚实:我测试了它在IE9中使用IE7模式)。



以下是代码:

 < html>< head> ;< /头> 
< body>
< div class =menu> HOME |产品|关于< / DIV>
< p>测试!< / p>< p>测试!< / p>< p>测试!< / p>< p>测试< / p>
< / body>
< / html>

相关的CSS,用几种颜色可视化事物:

  html {
background-color:green;
}

div.menu {
border:1px solid blue;
background-color:silver;
位置:绝对;
right:10px;
top:10px;
}

body {
background-color:pink;
宽度:90%;
职位:亲属;
left:10px;
top:10px;
}

给我如预期的那样:



它为我呈现类似的IE9和FF。


Im experiencing some really wierd behaviour in IE7. I want to position my <body> -tag relative.

If i type

body { position: relative; }

in my css file, my menu (which is position: absolute) doesn't work. But if i use

<body style="position: relative;">

It works. How can that possibly make a difference? There is not javascript that is removing the css attribute or something like that.

解决方案

Was curious about this, but as the question stands @thirtydot's comment seems to be correct: the answer is that there is no difference. I've created this jsfiddle which renders as expected in IE7 (to be completely honest: I tested it with IE7 mode in IE9).

Here's the code:

<html><head></head>
    <body>
        <div class="menu">HOME | PRODUCTS | ABOUT</div>
        <p>Testing!</p><p>Testing!</p><p>Testing!</p><p>Testing!</p>
    </body>
</html>

The relevant CSS, with a few colors to visualize things:

html {
    background-color: green;
}

div.menu {
    border: 1px solid blue;
    background-color: silver;
    position: absolute;
    right: 10px;
    top: 10px;
}

body {
    background-color: pink; 
    width: 90%;
    position: relative;
    left: 10px;
    top: 10px;
}

Gives me, as expected:

It renders similar in IE9 and FF for me.

这篇关于&LT;身体GT;位置:相对,内嵌VS.css文件(IE7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆