Centering images with WordPress
Tuesday, January 15th, 2008Can be the devil, depending on how your theme is configured and how good you are at CSS. Tonight, I struggled for longer than my geek-pride will let me admit, to get Jen’s blog to display centered images. Basically, if you have a section in your stylesheet that goes something like this:
.entry img {
border: 1px solid #888;
float: left;
margin: 5px 10px 5px 0;
}
Comment out the “float: left” like this:
.entry img {
border: 1px solid #888;
/*float: left;*/
margin: 5px 10px 5px 0;
}
Then you will be able to center images in the visual editor by clicking on an image and then the ‘align center’ button. Now, I will be the first to admit that there might be a better way of going about this, but what you see above worked for me, and will hopefully continue to work and not break something else. If anyone has a better solution / workaround, please let me know.
The above code is to make an image centered in the post, with text above and below the image. If you’re trying to center an image and wrap text around it, I cannot help you and I have not tested the above to see if that will work (wrapping text all the way around an image, is just silly in my opinion).