Last active
December 11, 2015 17:49
-
-
Save armoucar/4637446 to your computer and use it in GitHub Desktop.
Gera css para grid flexivel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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