简体   繁体   English

确定JavaScript中的可变宽度或固定宽度

[英]Determine fluid or fixed width in JavaScript

Is there a reliable way to tell whether a web page's layout is fixed or fluid? 有没有可靠的方法可以判断网页的布局是固定的还是流畅的? I don't care if it required a library like jQuery or MooTools so long as it's reasonably accurate. 我不在乎是否需要像jQuery或MooTools这样的库,只要它相当准确即可。

Typical width methods are going to give you pixels, but there's an answer here which should give you (in most cases) a percentage width if it is defined as such: get CSS rule's percentage value in jQuery 典型的width方法将为您提供像素,但是这里有一个答案,如果这样定义的话,应该(在大多数情况下)为您提供一个百分比宽度: 在jQuery中获取CSS规则的百分比值

Suspected caveats with this method: 用此方法怀疑的警告:

  • The width is declared in the first stylesheet (this could be modified as appropriate to search all stylesheets). 宽度在第一个样式表中声明(可以适当修改以搜索所有样式表)。
  • The width isn't an inline style. 宽度不是内联样式。
  • You know the major container element of the page (this would be an issue with any method). 您知道页面的主要容器元素(这对任何方法都是一个问题)。

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

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