4
I have a div
that contains another div
within, but this second div
(from within) contains a <img src="">
, how can I do to leave this div
with the image aligned in the center of the first div
? have tried vertical-align
, horizontal-align
and etc and nothing right.
#clientes-logo1
{
width: 250px;
height: 200px;
background-color: white;
margin: 5px 5px 5px 0;
display:inline-block;
}
#logotipo-clientes
{
width: 220px;
height: auto;
/* vertical-align: middle; -- não funciona */
/* horizontal-align: middle; -- não funciona */
margin: 50px 5px 0px 15px; /* se usar assim a div principal desalinha */
}
<div id="clientes">
<h1>Clientes</h1>
<div id="clientes-logo1">
<img id="logotipo-clientes" src="http://blog.grio.com/wp-content/uploads/2012/09/stackoverflow.png" title="" alt="">
</div>
</div>
Lined up vertically but not horizontally, I could even use
margin-top: 20%;
only if one image is larger than the other they were not exactly in the center of the main div.– RFL
@Rafaelacioly, what do you mean? With what I passed to you it aligns horizontally and not vertically. Anyway, you want to align in both directions. But in relation to what? Your div customers have heigth auto.
– buback
@Rafaelacioly, try it now.
– buback
my div of
logotipo-clientes
this one inside the divclientes-logo1
, the divclientes-logo1
is 250 per 200px, and the image div is 220 in width andauto em height para não distorcer
i would like the inside image (logo-customers) to be in the middle of the divclientes-logo1
– RFL
@Rafaelacioly, set a height for customers-logo1 and use the change I made. It should work.
– buback
seemingly worked only that if I use display: inline-block they don’t stand next to each other, and I don’t want the main div to fit the size of the image, I want the size to be fixed and the inside image to be in the middle of it.
– RFL
Let’s go continue this discussion in chat.
– RFL
Add a left: 50% and also a Translate pro X - something like this: http://jsfiddle.net/L1e8rymm/
– Ricardo
@Ricardo, good observation. I’ll add.
– buback