MattM
MattM

Reputation: 3217

Image alignment centered in Wordpress

I have seen this in a couple of theme installs in Wordpress where they don't have the CSS for aligncenter for images. I am trying to add it so the image at the top of this page will center but it isn't working:

http://www.estiponagroup.com/dev/estipona-group-makea-an-announcement-celebrating-its-non-rebranding/

HTML

<a href="http://www.estiponagroup.com/dev/wp-content/uploads/Header.jpg" class="fluidbox fluidbox-closed" id="fluidbox-1">
       <div class="fluidbox-wrap" style="z-index: 990;">
            <img width="540" height="160" alt="Header" src="http://www.estiponagroup.com/dev/wp-content/uploads/Header.jpg" class="wp-image-1114 size-full aligncenter" style="opacity: 1;">
             <div class="fluidbox-ghost" style="width: 540px; height: 160px; top: 0px; left: 0px;"></div>
             <div class="fluidbox-loader" style="width: 540px; height: 160px; top: 0px; left: 0px;"></div>
         </div>
 </a>

CSS:

img.aligncenter {margin:0 auto !important;}

What am I missing?

Upvotes: 0

Views: 886

Answers (1)

isherwood
isherwood

Reputation: 61055

Images are inline by default, and therefore can't be positioned with margin.

img.aligncenter {
    margin:0 auto !important;
    display: block;
}

Also, the width and height attributes are deprecated (and won't work in IE10+). Use style instead.

Upvotes: 3

Related Questions