为什么Internet Explorer 7上的绝对位置父级中的百分比宽度子级元素中的宽度崩溃了? [英] Why did the width collapse in the percentage width child element in an absolutely positioned parent on Internet Explorer 7?

查看:50
本文介绍了为什么Internet Explorer 7上的绝对位置父级中的百分比宽度子级元素中的宽度崩溃了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绝对定位的 div ,其中包含多个子元素,其中一个是相对定位的 div .当我在子级 div 上使用基于<百分比>的宽度时,在IE7上它会折叠为 0宽度,但在Firefox或Safari上不会.

I have an absolutely positioned div containing several children, one of which is a relatively positioned div. When I use a percentage-based width on the child div, it collapses to 0 width on IE7, but not on Firefox or Safari.

如果我使用像素宽度,它可以工作.如果父母位置相对,则孩子的百分比宽度会起作用.

If I use pixel width, it works. If the parent is relatively positioned, the percentage width on the child works.

  1. 这里有我想念的东西吗?
  2. 除了子对象上的基于像素的宽度之外,还有其他简便的解决方法吗?
  3. CSS规范中是否有涵盖此方面的内容?
  1. Is there something I'm missing here?
  2. Is there an easy fix for this besides the pixel-based width on the child?
  3. Is there an area of the CSS specification that covers this?

推荐答案

父级 div 必须具有定义的 width (以像素或百分比表示).在Internet Explorer 7中,父级 div 需要定义的 width 才能使子百分比 div 正常工作.

The parent div needs to have a defined width, either in pixels or as a percentage. In Internet Explorer 7, the parent div needs a defined width for child percentage divs to work correctly.

这篇关于为什么Internet Explorer 7上的绝对位置父级中的百分比宽度子级元素中的宽度崩溃了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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