Mozilla / Firefox忽略SPAN / DIV的宽度 [英] Mozilla/Firefox ignoring width for SPAN/DIV

查看:76
本文介绍了Mozilla / Firefox忽略SPAN / DIV的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试制作不同长度的水平条。我认为,无论是SPAN还是DIV都可以使用
,但它只适用于IE。我有一个小的

示例: http://sedivy.com /test.htm

如果我错过了什么,请告诉我。


谢谢,

Lac

解决方案

la *@myrealbox.com 写道:

我正在尝试制作不同长度的水平条。我认为无论是SPAN还是DIV都可以工作,但它只适用于IE。我有一个小例子: http://sedivy.com/test.htm




根据CSS规则,width属性不适用(即忽略)

非替换内联元素。因此,IE的作用是错误的。


无法猜出你想要实现什么,以及可能是实现它的最佳方式。请提供一个真实示例的URL,

最好是在您通过良好的创作原则进行首次设计之后 -
特别是
,并充分考虑页面如何在没有CSS的情况下工作并且

如何在非视觉演示中工作。


-

Yucca, http://www.cs.tut.fi/~jkorpela/


la *@myrealbox.com 写道:

大家好,
我正在尝试制作不同长度的水平条。我认为无论是SPAN还是DIV都可以工作,但它只适用于IE。我有一个小例子: http://sedivy.com/test.htm
如果我错过了什么,请告诉我。




您在内联元素上使用了''width''属性,但CSS规范

说:


"此属性不适用于未替换的内联级元素。


< URL:http://www.w3.org/TR/CSS21/visudet.html#the-width-property>


你的跨度没有内容,所以虽然背景设置为你定义的颜色,你不能看到它们。在

跨度或div中放入一些文本,Firefox会显示你的背景颜色(但仍然没有

尊重你的宽度建议)。


我认为IE在这种情况下是错误的 - 它不应该像它那样显示空内联

元素。


如果你想要的话show应该在一个表中,然后使用

表格单元格而不是跨度或内联div。


-

Rob


la *@myrealbox.com 写道:

大家好,
我正在尝试制作不同长度的水平条。我认为无论是SPAN还是DIV都可以工作,但它只适用于IE。我有一个小例子: http://sedivy.com/test.htm
如果我错过了什么,请告诉我。




< style type =" text / css">

span {display:-moz-inline-box; / * Gecko专有* /

显示:inline-block; / *受Opera支持? * /

宽度:25%;身高:1em; / *所需的宽度和高度* /

vertical-align:top; / * Gecko需要这个* /

} / * IE,Opera& Gecko轻微差异* /

< / style>


-

Gus


Hello all,
I am trying to make horizontal bars of different lengths. I tought
either SPAN or DIV would work but it only works for IE. I have a small
example at: http://sedivy.com/test.htm
Let me know if I missed something.

Thanks,
Lac

解决方案

la*@myrealbox.com wrote:

I am trying to make horizontal bars of different lengths. I tought
either SPAN or DIV would work but it only works for IE. I have a small
example at: http://sedivy.com/test.htm



By CSS rules, the width property does not apply to (i.e., is ignored for)
non-replaced inline elements. Thus, what IE does is wrong.

It is impossible to guess what you are trying to achieve and what might be
the best way to achieve it. Please provide the URL of a real example,
preferably after you have first designed it by good authoring principles -
in particular, with due consideration of how the page works without CSS and
how it works in non-visual presentation.

--
Yucca, http://www.cs.tut.fi/~jkorpela/


la*@myrealbox.com wrote:

Hello all,
I am trying to make horizontal bars of different lengths. I tought
either SPAN or DIV would work but it only works for IE. I have a small
example at: http://sedivy.com/test.htm
Let me know if I missed something.



You have used the ''width'' property on inline elements, but the CSS spec
says:

"This property does not apply to non-replaced inline-level elements."

<URL:http://www.w3.org/TR/CSS21/visudet.html#the-width-property>

Your spans have no content, so although the backgrounds have been set to
the colours you define, you can''t see them. Put some text inside the
spans or divs and Firefox will show your background colour (but still no
honour your width suggestion).

I think IE is wrong in this case - it should not show empty inline
elements the way it does.

If what you are trying to show really should be in a table, then use
table cells and not spans or inline divs.

--
Rob


la*@myrealbox.com wrote:

Hello all,
I am trying to make horizontal bars of different lengths. I tought
either SPAN or DIV would work but it only works for IE. I have a small
example at: http://sedivy.com/test.htm
Let me know if I missed something.



<style type="text/css">
span {display:-moz-inline-box; /* Gecko proprietary */
display:inline-block; /* supported by Opera and ? */
width:25%;height:1em; /* width and height required */
vertical-align:top; /* Gecko needs this */
} /* IE, Opera & Gecko slight diff */
</style>

--
Gus


这篇关于Mozilla / Firefox忽略SPAN / DIV的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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