我正在制作一个复选框绘图程序,用户可以在其中绘制带有复选框的图片。我需要禁用复选框上的自动换行符,因为它们超出了行尾并弄乱了方块。例如,如果我尝试绘制一个 100*100 的正方形,会发生以下情况:
显然,这不是我想要的。当屏幕空间不足时,如何禁用自动换行符以显示水平滚动条?
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<style type = "text/css">
.drawcheck
{
display:inline-block;
vertical-align:top;
}
</style>
<script type = "text/javascript">
function drawBoxes()
{
var html = "";
for(var i = 0;i<100;i++)
{
for(var j = 0;j<100;j++)
{
html += "<input type = 'checkbox' class = 'drawcheck'>";
}
html += "<br />";
}
document.getElementById('drawarea').innerHTML = html;
}
function clearAll()
{
var w = document.getElementsByTagName('input');
for(var i = 0; i < w.length; i++){
if(w[i].type=='checkbox'){
w[i].checked = false;
}
}
}
</script>
<title>Checkbox drawer</title>
</head>
<body onload = "drawBoxes()">
<div id = "controlbar" style = "height:100px;float:top;background-color:#FF0000;"><input type = "button" onclick = "clearAll()" value = "Clear"/></div>
<div id ="drawarea" style = "text-align:center"></div>
</body>
</html>