IE11中的CSS位置未设置 [英] CSS Position Unset in IE11

查看:170
本文介绍了IE11中的CSS位置未设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绝对定位的megamenu,并且由于其某些父元素需要具有position:relative,因此我必须在直接父对象上使用position:unset.这在Chrome和Firefox中有效,但是IE11不支持unsetinitial.

I have a megamenu that is absolutely positioned, and as some of its parent elements need to have position:relative, I have to use position:unset on the direct parent. This works in Chrome and Firefox, however IE11 does not support unset or initial.

我不能简单地从所有父元素中删除相对位置,因为这会破坏其他内容,但是我必须使megamenu相对于页面绝对定位(固定位置不起作用). unset是否可以在IE11中使用?

I can't simply remove the relative positioning from all of the parent elements as that will break other things, but I have to have the megamenu absolutely positioned relative to the page (fixed position does not work). Is there an alternative to unset that will work in IE11?

推荐答案

unset表示

如果属性的级联值为unset关键字,则如果它是继承的属性,则将其视为inherit,否则,将其视为.该关键字有效清除了所有已声明的值

If the cascaded value of a property is the unset keyword, then if it is an inherited property, this is treated as inherit, and if it is not, this is treated as initial. This keyword effectively erases all declared values occurring

在您的情况下,position不是继承的属性,因此它将始终考虑initial

In your case, position is not an inherited property so it will always consider initial

每个属性都有一个初始值,该初始值在属性的定义表中定义.

Each property has an initial value, defined in the property’s definition table.

对于position,它是static,因此您可以简单地使用position:static,它的行为与position:unset

For position, it's static So you can simply use position:static and it will behave the same as position:unset

参考: https://drafts.c​​sswg.org/css-cascade-3/

要使其更通用,您必须使用:

To make this more generic you have to either use:

  • property:inherit,如果这是继承的财产
  • property:<initial_value>(如果不是继承的话).然后,您可以查看属性的定义表以找到初始值.
  • property:inherit if it's an inhertied propety
  • property:<initial_value> if it's not an inhertied propety. Then you look at the property’s definition table to find the initial value.

https://developer.mozilla.org/zh-CN/docs/Web/CSS/position

这篇关于IE11中的CSS位置未设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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