我有一个带有背景图像的 div 元素。图像是无法剪切的图案,因此它始终必须在图像的底部结束。图像高度为 400 像素。所以我希望 div 始终为 400px 或更高,但它必须除以 400px 以便在文本溢出时背景图像不会被切掉。示例:400px->800px->1200px 等。
问问题
69 次
1 回答
0
if the content ain't changed after the page load u can use a simple javascript:
window.onload = function(){
var divs = document.getElementsByClass('exampleClass');
for(var i=0;i<divs.length ; i++)
if(divs[i].clientWidth % 400 != 0)
divs[i].clientWidth += 400 - (divs[i].clientWidth % 400);
}
于 2013-06-13T19:23:46.773 回答