Bootstrap 列宽度根据您使用的设备和方向而有所不同。
是否有任何帮助程序可以告诉我某些 css 选择器的当前列宽,或者只是像“col-md-3”这样的 boostrap 类?
我正在将 D3.js 图表集成到 Bootstrap 网格中,并且我需要为 D3 提供我希望图表适合的绝对大小。
最佳答案
当您准备好生成图表时,可以使用 jquery innerWidth
函数来获取元素的宽度。这可能应该是在页面加载之后。
当窗口大小发生变化时,您还需要执行类似的操作来获取宽度。
Javascript
$( window ).resize(function() {
//if the chart takes a while to compute you may also consider a timing
//function to only calculate after a few hundred milliseconds of the size
//being the same.
var width = $( "#mychart" ).innerWidth();
//remove and rebuild the chart.
});
关于twitter-bootstrap - Bootstrap中如何判断列宽?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33868951/