我正在尝试在 iPad 上调试网站。在桌面上,某个元素会显示,但在 iPad 上,该元素会丢失。
Question:
有没有一种方法可以在一个语句中输出所有CSS,类似于
console.log( $('element').attr('class') );
或者是找到错误属性的唯一方法是一一检查所有 CSS 规则?
console.log( $('element').css('position') )
console.log( $('element').css('top') )
console.log( $('element').css('left') )
console.log( $('element').css('right') )
console.log( $('element').css('bottom') )
console.log( $('element').css('width') )
console.log( $('element').css('height') )
console.log( $('element').css('display') )
... you get the point...
感谢您的意见
你需要window.getCompatedStyle https://developer.mozilla.org/en/DOM/window.getComputedStyle:
getCompatedStyle() 给出所有 CSS 的最终使用值
元素的属性。
所有现代浏览器(包括 IE9)均支持。
一个简单的例子:
var style = window.getComputedStyle($('element').get(0), null);
jsFiddle 演示 http://jsfiddle.net/Pbe4N/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)