Reputation: 41
I created a grid in a Google web app. I was hoping to get the grid to the size (0px, 0px), but I get (12px, 0px) since every column inside of the grid seems to have 4px added to their width for no reason.
Here's what was done to the grid (all at once):
*Note: no borders or margins were used on the grid nor the cells inside of it.
Here's some code you can try to see what I'm talking about.
function doGet() {
var app = UiApp.createApplication();
var grid = app.createGrid(3,3);
//Used outlines since they don't affect the size of the object
grid.setStyleAttribute("outline-style","solid");
grid.setStyleAttribute("outline-width","1px");
grid.setStyleAttribute("outline-color","red");
grid.setCellPadding(0);
grid.setCellSpacing(0);
grid.setStyleAttribute("width","0px");
grid.setStyleAttribute("height","0px");
grid.setStyleAttribute("line-height","0px");
grid.setStyleAttribute("padding","0px");
for(var x = 0; x<3; x++){
for(var y = 0; y<3; y++){
grid.setStyleAttribute(y,x,"width","0px");
grid.setStyleAttribute(y,x,"height","0px");
grid.setStyleAttribute(y,x,"line-height","0px");
grid.setStyleAttribute(y,x,"padding","0px");
}
}
app.add(grid);
app.add(app.createLabel("^ The grid is right here. It's width is non-zero for some reason"));
return app;
}
Upvotes: 1
Views: 433
Reputation: 408
There are two issues here:
The cells are automatically populated with
, so that needs to be cleared (removes 3 * 3px), and
webkit has a bug which leaves an effective 1px width for a cell set to zero width meaning that your only option to drop below 3px is to set the cell to display:none
Try adding these lines to your loop:
grid.setStyleAttribute(y,x,"display","none");
grid.setText(y, x, "")
Upvotes: 2