简体   繁体   English

width 和 style.width 接受哪些数据类型?

[英]What data types do width and style.width accept?

I am a first time JavaScript student and I have a school question, we need to indicate the data types that width and style.width accept.我是第一次 JavaScript 学生,我有一个学校问题,我们需要指出 width 和 style.width 接受的数据类型。

I know data types are number, string, null, undefined, boolean and object.我知道数据类型是数字、字符串、空值、未定义、布尔值和对象。 We haven't learned to code yet so I don't know how to test my answers nor can I find it on the web.我们还没有学会编码,所以我不知道如何测试我的答案,也无法在网上找到它。

The properties on the style object is based on the CSS spec, specified as a String value eg element.style.width = '10px' .样式对象的属性基于 CSS 规范,指定为字符串值,例如element.style.width = '10px' As for width, please read more here .至于宽度,请在此处阅读更多内容。 More specifically what is eligible to be used, please see width<length> and width<percentage>更具体地说,什么是有资格使用的,请参阅width<length>width<percentage>
If you try to set an invalid value, it will be invalidated and not applied on the element.如果您尝试设置无效值,它将无效并且不会应用于元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM