Div显示:初始在ie10和chrome 29中未按预期工作 [英] Div display:initial not working as intended in ie10 and chrome 29

查看:96
本文介绍了Div显示:初始在ie10和chrome 29中未按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示一个具有以下限制的div:

I want to display a div with the following restrictions:


  • 自动隐藏宽度为1024像素以下

  • 可以在1024像素宽度下通过按钮切换,但如果我点击somwhere(不在div内)应该删除 activeDiv

  • automatically hide under 1024px width
  • can be toggle by button under 1024px width, but if I click somwhere (not inside the div) the activeDiv class should be removed

我在代码上有一个虚拟示例

因此出现以下问题:


  • 在IE10中,切换按钮工作(不隐藏/显示div)我用开发人员工具检查,但没有显示的迹象:初始

  • 29 the div appeard next the button not under it。 (Firefox是相同的)

    我知道div的默认显示 block 但这个css不仅仅是 div 标签,因此我尝试使用初始

  • In IE10 the toggle button just not work (not hide/show the div) I check with the developer tools, but no sign of the display: initial
  • In Chrome 29 the div appeard next the button not under it. (Firefox is the same)
    I know that the default display for div is block, but this css is not only for div tags that's why I try to use initial.

推荐答案

初始 给定元素的给定属性的默认值。它意味着规范定义的给定属性的默认值。 显示的初始值为 inline ,而不是此处所述。这是不管你应用它的什么样的元素。如前所述,IE不支持初始关键字。

initial does not mean "the default value of a given property for a given element". It means "the default value of a given property as defined by the spec". The initial value of display is inline, not block, as stated here. This is regardless of what sort of element you apply it to. And as already mentioned, IE does not support the initial keyword.

如果你想要一个元素显示为一个块,使用 display:block 。如果你想要在内联显示,使用 display:inline 。如果您希望使用浏览器默认值,请不要设置 display

If you want an element to be displayed as a block, use display: block. If you want it to be displayed inline, use display: inline. If you want it to use whichever is the browser default for it, do not set the display property at all.

这篇关于Div显示:初始在ie10和chrome 29中未按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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