要准确获取元素的clientWidth,可以通过以下方法:
var element = document.getElementById('myElement');
var width = element.clientWidth;
console.log(width);
var element = document.getElementById('myElement');
var style = window.getComputedStyle(element);
var width = parseInt(style.getPropertyValue('width'), 10);
console.log(width);
var element = document.getElementById('myElement');
var width = element.offsetWidth;
console.log(width);