Skip to content

Instantly share code, notes, and snippets.

@armoucar
Last active December 11, 2015 17:49
Show Gist options
  • Save armoucar/4637446 to your computer and use it in GitHub Desktop.
Save armoucar/4637446 to your computer and use it in GitHub Desktop.
Gera css para grid flexivel
public class CalculandoGridFlexivel {
public static final DecimalFormat df = new DecimalFormat("#.####");
public static void main(String[] args) {
float width = 1080;
float espacamento = 10;
float qtdTotaisDeColunas = 8;
float tamanhoDaMenorColuna = (width / qtdTotaisDeColunas) - (espacamento * 2);
for (int qtdColunas = 1; qtdColunas <= qtdTotaisDeColunas; qtdColunas++) {
float tamanhoDaColuna = tamanhoDaMenorColuna * qtdColunas + espacamento * ((qtdColunas - 1) * 2);
float tamanhoRelativoDaColuna = tamanhoDaColuna / width * 100;
System.out.println(".grid_" + ((int) qtdColunas) + " { width: " + df.format(tamanhoRelativoDaColuna) + "%; } /** " + (int) tamanhoDaColuna + "px **/");
}
System.out.println("margin: " + (espacamento / width * 100) + "%");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment