首先,
尝试将 CSS 应用到每个 div,
#master{
width:100%;
}
#child1, #child2, #child3{
width:33.33%;
display: inline-block;
}
除此之外,您可以使用 JavaScript 来满足您的要求,在</body>
您需要在下面包含此 javascript 之前什么都没有:
var child1 = document.querySelector('#child1');
var child2 = document.querySelector('#child2');
var child3 = document.querySelector('#child3');
if((child1.offsetHeight < child1.scrollHeight) || (child1.offsetWidth < child1.scrollWidth)&&(child2.offsetHeight < child2.scrollHeight) || (child2.offsetWidth < child2.scrollWidth)&&(child3.offsetHeight < child3.scrollHeight) || (child3.offsetWidth < child3.scrollWidth)){
// your element have overflow
child1.style.width = "100%";
child2.style.width = "100%";
child3.style.width = "100%";
}
else{
//your element don't have overflow
}