Html IE11 CSS 替代“未设置”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48425453/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
IE11 CSS alternative to "unset"
提问by Mike
I have a fixed div on my page which is positioned with the following CSS properties:
我的页面上有一个固定的 div,它使用以下 CSS 属性定位:
width: 320px;
height: 160px;
position: fixed;
right: 15px;
bottom: 15px;
top: unset;
z-index: -1;
The div appears fine in the bottom right of the page in other browsers, but in Internet Explorer 11 the div appears in the top right. I believe this issue is coming from top: unset;
which doesnt appear to be supported in IE.
div 在其他浏览器的页面右下角显示正常,但在 Internet Explorer 11 中,div 显示在右上角。我相信这个问题来自top: unset;
IE 似乎不支持。
Are there any workarounds using CSS or JS that could be used to achieve the same positioning?
是否有任何使用 CSS 或 JS 的解决方法可用于实现相同的定位?
回答by Bram Vanroy
You are looking for top: auto
, it seems.
你正在寻找top: auto
,似乎。
回答by Mentalist
While top:auto
will work in the case of top
, it should be mentioned that auto
is not simply an "IE equivalent" to unset
or initial
.
虽然top:auto
在的情况下将工作top
,它应该提到的是auto
不是一个单纯的“IE相当于”unset
或initial
。
For example, the initial value for max-width
is none
(source). And the initial value for background-color
is transparent
(source). Each CSS property has an initial value, and for IE it must be explicitly set.
例如,对于初始值max-width
是none
(源)。和初始值background-color
是transparent
(源)。每个 CSS 属性都有一个初始值,对于 IE,它必须显式设置。
Initial values are listed on sites such as MDN, and w3schools(where they are called "default values").
初始值列在MDN和w3schools等网站上(它们被称为“默认值”)。
With a question title like IE11 CSS alternative to “unset”many people will find this page from a search engine who have needs that differ from OP's. So I think an explanation of how to look up initial values is more valuable than a "just use this" type of answer.
使用诸如IE11 CSS 之类的问题标题来替代“未设置”,许多人会从搜索引擎中找到此页面,他们的需求与 OP 的需求不同。因此,我认为对如何查找初始值的解释比“仅使用此”类型的答案更有价值。
回答by Jasmine Ibikunle
In my case top: auto
didn't work, I had a bottom value instead. The default value is position: static
and this worked for me in IE 11.
在我的情况下top: auto
不起作用,我有一个底部值。默认值是position: static
,这在 IE 11 中对我有用。