Div in circles with responsive layout

4

I'm trying to make a page where they contain div in circles and adjust one below the other when layout decreases, for example, to cell sizes. With the usual size I would like them to be side-by-side, and as they go down, stay one below the other. I read something about media queries and I'm trying to implement it, but if anyone knows and could help me with something.

I also can not leave a little space between div .

Here's the code I'm currently using:

.center-content {
  border: solid 1px #000;
  width: 100%;
}

.center-content div {
  border-radius: 50%;
  display: table-cell;
  vertical-align: middle;
  text-align: center;
  width: 100px;
  height: 100px;
  background-color: #229922;
}
<div class="center-content">
  <div>Texto</div>
  <div>Texto</div>
  <div>Texto</div>
  <div>Texto</div>
  <br/>
  <div>Texto</div>
  <div>Texto</div>
  <div>Texto</div>
  <div>Texto</div>
</div>
    
asked by anonymous 28.03.2015 / 00:46

1 answer

7

I was able to find two alternatives:

  • Using inline-block
  • Using inline-flex
  • Using inline-block

    To have more scope you can use the display inline-block like this:

    .master {
    	border: solid 1px #000;
    	max-width: 500px;
        font-size: 0;
    }
    
    .master div {
        border-radius: 50%;
        display: inline-block;
        text-align: center;
        margin: 10px;
        width: 100px;
        line-height: 100px;
        background-color: #229922;
        font-size: 40px;
    }
    
    body{
        color: white;
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><buttononclick="$('.master').width($('.master').width()-25)">Clique para reduzir largura em 25px</button>
    <button onclick="$('.master').width($('.master').width()+25)">Clique para reduzir largura em 25px</button>
    <div class="master">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
        <div>6</div>
        <div>7</div>
        <div>8</div>
    </div>

    jsFiddle: it is easier to resize with the mouse

    Using inline-flex

    If you do not have restrictions on using some more modern CSS like inline-flex , you can do this:

    .master {
    	border: solid 1px #000;
    	max-width: 500px;
        font-size: 0;
    }
    
    .master div {
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin: 10px;
        width: 100px;
        height: 100px;
        background-color: #229922;
        font-size: 40px;
    }
    
    
    body{
        color: white;
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><buttononclick="$('.master').width($('.master').width()-25)">Clique para reduzir largura em 25px</button>
    <button onclick="$('.master').width($('.master').width()+25)">Clique para reduzir largura em 25px</button>
    <div class="master">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
        <div>6</div>
        <div>7</div>
        <div>8</div>
    </div>

    jsFiddle: it is easier to resize with the mouse

        
    28.03.2015 / 03:14