[英]Style attribute in firefox
i am using a piece of code in js as:-我在 js 中使用一段代码作为:-
span_1.style.width = '30%'
input_1.style.width = '40%';
td_1.style.cursor = 'hand';
where span_1
, input_1
, td_1
are span
, input
, td
objects, resp.其中span_1
、 input_1
、 td_1
分别是span
、 input
、 td
对象。
All are not working in firefox?Any suggestions...所有这些都不能在 firefox 中工作?任何建议......
not quite sure, but I guess you'll have to display them as 'block' first, since spans are inline-elements.不太确定,但我想你必须首先将它们显示为“块”,因为跨度是内联元素。 Also, the parent element should have a width set.此外,父元素应设置宽度。
so in css: display: block;所以在 css 中:显示:块;
//edit: //编辑:
display: inline-block;显示:内联块;
may even be better.甚至可能会更好。
Some browsers put all elements with an id as properties in the window
object so that you can access them directly, but this is not a web standard.一些浏览器将所有具有 id 的元素作为属性放在window
object 中,以便您可以直接访问它们,但这不是 web 标准。 Use the getElementById
method to access elements:使用getElementById
方法访问元素:
document.getElementById('span_1').style.width = '30%';
document.getElementById('input_1').style.width = '40%';
document.getElementById('td_1').style.cursor = 'pointer';
First: the hand
value for cursor
is Microsoft's proprietary implementation of what every other browser calls pointer.
首先: cursor
的hand
值是微软专有的实现,其他浏览器都称之为pointer.
I think you have to go back to IE5 to find an IE that doesn't support pointer
so use that instead.我认为您必须 go 回到 IE5 才能找到不支持pointer
的 IE,因此请改用它。
If you want to support browsers that don't understand pointer
then change the .className
instead and have a style predefined:如果您想支持不理解pointer
的浏览器,请改为更改.className
并预定义样式:
.foo {
cursor: hand;
cursor: pointer;
}
Second: The width property does not apply to display: inline
elements (which a <span>
is by default).第二: width 属性不适用于display: inline
元素(默认情况下是<span>
)。 IE may get this wrong in quirks mode, which leads to many inconsistances. IE 在 quirks 模式下可能会出错,从而导致许多不一致。 Make sure you are in standards mode .确保您处于标准模式。
If you are using a span, then change it to a block element, or style the display so it isn't inline (eg display: inline-block;
).如果您使用的是跨度,则将其更改为块元素,或设置显示样式以使其不是内联(例如display: inline-block;
)。
Third: You don't specify how you get the reference to the elements in the respective variables.第三:您没有指定如何获取对各个变量中元素的引用。 IE has a tendency to splurge global variables that match the id of any given element. IE 倾向于使用与任何给定元素的 id 匹配的全局变量。 This is non-standard and can't be relied upon.这是非标准的,不能依赖。 Make sure you get proper references.确保你得到正确的参考。 eg例如
var span_1 = document.getElementById('span_1');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.