Centering images with WordPress
Can 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).
January 15th, 2008 at 1:00 am
You’s so very helpful!!
March 11th, 2008 at 8:34 am
Actually it just removes the float for img tag within “entry” div. To center an image you need either put inside <center> </center> tags or inside a div with align=”center”
Wrapping text all the way is a bit “tricky” and can be done using tables..
anywho, cheers on Recapture plugin
March 11th, 2008 at 8:40 pm
Hmmm, I want to say that we tried something like that, and couldn’t get it to work. Maybe it was just the theme we were using.
When I have some spare time, I’ll have to check this out though. Thanks.
May 5th, 2008 at 10:31 pm
Thank you so much for this, I spent hours fighting my blog to get the images where they should be. Feel stupid now, oh well.
June 2nd, 2008 at 9:11 pm
You my friend are the greatest!!
September 10th, 2009 at 10:27 am
Just needed to drop a thanks. After fiddling unsuccessfully for over an hour to do something as simple as centering an image, your solution was the only thing that worked for me. Thank you so much for taking the time to post it.