Images don’t right align in WordPress

I recently added a new WordPress template to one of my sites and found that the right align option did not work. The Alignment was set correctly in the upload “Edit Image” settings and appeared correct in the “Advanced settings” but when you preview the image was still at the left hand side. I looked up various WordPress sites for the answer and it appears that the style sheets of many of the themes are old and need updating to work on more modern versions of WordPress. Several sites suggested adding the following code:

img.centered {
display: block;
margin-left: auto;
margin-right: auto;
}

img.alignright {
padding: 4px;
margin: 0 0 2px 7px;
display: inline;
}

img.alignleft {
padding: 4px;
margin: 0 7px 2px 0;
display: inline;
}

.alignright {
float: right;
}

.alignleft {
float: left;
}

The replies from various happy forum readers suggested that the code fixes the problem, but it didn’t do so on my chosen theme GabLog 1.0

After some more research I finally found the answer one line of code

.alignright { float: right !important; margin:0 0 15px 15px !important; }

Simply place this in the css style sheet. You’ll find this in the wp-admin page under “Appearance” and sub menu “Editor” From there look at the Theme files on the right, select Stylesheet (style.css) from Styles and add the above line of code in to the centre edit box. Click on update File and you should then find your image aligns to the right when you refresh.

Leave a Reply

Your email address will not be published. Required fields are marked *