what’s the best way to force DIV to fill specified width?
I have the following code that generates and assign width to DIV:
function createLabel(str) {
var textDiv = document.createElement('div');
textDiv.style.width = '200px';
textDiv.style.display = 'inline';
textDiv.appendChild(document.createTextNode(str));
return textDiv;
}
I want created DIV’s to have the same width, whatever text length is.
You might run into trouble specifying both a width and
display = 'inline'. The width won’t have any effect. You’ll need to keep the default display mode for adivelement, i.e.block. If you need other elements at the same horizontal position, you’ll need to usefloatas well.