Stefano Maglione
Stefano Maglione

Reputation: 4150

Use float to align div elements

I am trying to align some div tag containing some images for a small gallery. I used float:right and seems working but for some reason in some row instead of having a div the space is simply empty and the div is in the next row jumping to it. You can see it here : example

<div class='gridImage' >
    <div class='titel'>".$row['titel']."</div><br/>
    <img class='ritratti' data-size='". $row['size']. "' data-itemnr='". $row['itemNr']. "'  src='uploads/".$row['img']."'/><br/>
    <div>".$row['size']."</div><br/>
</div>";


.gridImage{

width:40%;
float:right;
padding:10px;
display:inline;
text-align:center;
}

Upvotes: 0

Views: 51

Answers (1)

Dalin Huang
Dalin Huang

Reputation: 11342

try this?

.gridImage {
    width: 40%;
    display: inline-block;
    text-align: center;
}

Upvotes: 1

Related Questions