I can not accommodate three images online

2

I'm trying to leave three images per line on a page, set this in the body of the page:

        <div class="produtos-ponta">
      <div class="produtos-conteudo-ponta one-fourth-ponta"><img class="photo" src="imagens-ponta/amsterdam.jpg"/>
        <div class="content">
          <h4 class="name">Descricao</h4>              
        </div>
      </div>
      <div class="produtos-conteudo-ponta one-fourth-ponta"><img class="photo" src="imagens-ponta/arezzo.jpg"/>
        <div class="content">
          <h4 class="name">Descricao</h4>              
        </div>
      </div>
      <div class="produtos-conteudo-ponta one-fourth-ponta"><img class="photo" src="imagens-ponta/belmont.jpg"  />
        <div class="content">
          <h4 class="name">Descricao</h4>              
        </div>
      </div>                    
    </div>

And this in my css:

.produtos-conteudo-ponta {
    position:relative;
    text-align: center;
    margin-bottom: 20px;
    height: 320px;
    float:left;
}

.produtos-conteudo-ponta .photo {   
    max-width:320px;
    max-height:196px;
    width: auto;
    height: auto;   
}

.produtos-ponta {
    position:relative;
}

.one-fourth-ponta {
    width: 20.5%;   
    max-width: 320px;
}

But the images break the line, I would like to leave them in only one.

The preview page is this: Page

    
asked by anonymous 17.07.2015 / 22:43

2 answers

2

Just add display: inline-block; to class: produtos-conteudo-ponta

.produtos-conteudo-ponta {
    display: inline-block;
}

Update

To add a larger spacing between the images you can use the margin a>. Such as margin-left:10px; or margin-right:10px; . Or even add both so that they are more or less with an equal margin for both sides.
However I would approach it differently.

As we have 3 divs online (inline), I would do the following calculation:

  

100 to divide with 3 that gives = 33.333333
  This calculation will be - 100% the size of div parent to divide by 3 divs child

then the width size for the class produtos-conteudo-ponta will be 33.333333% making them equal equal in size, and responsive to div parente . (this thinking already in the possibility of this being able to be resized later in screens of small resolutions)

.produtos-conteudo-ponta {
    display: inline-block;
    width: 33.333333%;
}

Next you would modify the HTML markup code hierarchy as follows:

<div class="produtos-conteudo-ponta one-fourth-ponta">
    <div class="content">
        <img class="photo" src="/imagens-ponta/amsterdam.jpg"/>
        <h4 class="name">Descricao</h4>              
    </div>
</div>

In the above code, we modified the image to be included within the .content class for the following reason:

Instead of changing class by class and add attributes to each of them, for example - margins, spaces etc times and times without count, instead we will only apply the styles to class .content :

.content {
    display: block;     /* Poderíamos adicionar também width:100%; mas ao adicionarmos este atributo o width:100%; já está a ser aplicado */
    max-width: 200px;   /* Isto especifica que nós não queremos que a div cresça mais do que os 200px */
    margin: 0 auto;     /* Isto centraliza a div ao centro por igual - para ambos, a margem esquerda e a margem direita. É nesessário o display:block; acima já adicionado para que isto funcione correctamente */
}
.photo {width: 100%;}   /* E por fim a imagem ficará a 100% da div "content". que neste caso será o máximo de 200px */

Here is an online example of this in jsFiddle ► link

Drag the jsFiddle viewport to see its behavior at various resolutions. To increase or decrease the spacing between them, just play with the value max-width:200px;

    
17.07.2015 / 22:48
2

Test with this css:

.produtos-conteudo-ponta{
    float:left
}

It causes all elements of class .produtos-conteudo-ponta to float on the left, so Bloquinhos are side by side.

As stated above, the effect can also be achieved with display: inline-block;

Fiddle: Link to see online

    
17.07.2015 / 22:46