将内容置于div中。 无法进入中心

I have the code below in a site but can't get to center everything within the main div (rightBarItems):

<div class="rightBarItems">
<?php
echo "<div class='similarTitle'>YOU MAY ALSO LIKE</div>";
while ($row3 = $result3->fetch())
{
echo "<div class='similarItems'>";
echo "<a href='items_descr.php?itemId=".$row3[id_item]."'><img class='similarImage' src='images/{$row3[thumb1]}.jpg'></img>";
echo "<div class='similarItemsText'>".$row3[name]."</div></div>";
}
?>

Then, here is my css:

    .similarTitle {
    font-family:"Century Gothic","Trebuchet MS",Helvetica,Arial,sans-serif;
    font-size:15px;
    text-transform:uppercase;
    color:#3E3E3E;  
    }
.rightBarItems
{
margin: 0 auto;
width: 168px;
background: #F3EFE2;
padding: 10px;
float: right;
text-align: center; 
height: 300px;
}
    .similarItems { 
    float: left;
    text-align:center;
    margin: 0 auto;
    padding: 5px;
     }
    .similarItemsText { 
    padding-right: 11px;
    margin: 0 auto;
    font-family: verdana,Helvetica,Arial,sans-serif;
    font-size: 11px;
    color: #666;
     }
     #similarImage {
     margin: 0 auto;

     border: 1px solid gray;
     float: left;
     }

Not everything gets centered... Any help? Thanks!! * Adding some extra CSS I had forgot to put

Try This in CSS

.rightBarItems{  text-align:center ; }

or

.rightBarItems > div { margin-left:auto ; margin-right:auto; }

Use:

text-align:center;

For all of these CSS classes: rightBarItems, similarTitle, similarItemsText, similarImage.

Well, firstly, you have different padding values for each class so that will first prevent them from aligning.

If you are ok with leaving a paragraph space between the texts then align=center should work with the paragraph tag instead of fixing the whole CSS code.

<p align="center"> Centered Text </p>

Remove the float:right style from the rightBarItems div.