This can be done with by using an inline-block
display, the float:left
will always send the elements to their furthest left possible.
.gallery {
text-align: left;
border-style: solid;
border-width:3px;
border-top-left-radius: 40px;
border-bottom-right-radius: 40px;
background:yellow;
width:335px;
padding:20px;
/*float:left; remove this*/
margin:15px;
/*add this*/
display:inline-block;
position:relative;
}