We help IT Professionals succeed at work.

CSS - Centering an image

GileadIT asked
Last Modified: 2017-04-06
At first glance this may seem simple but I have been struggling with this all morning and now I am crying uncle! Here we go....

I have the following code...
<div class="panel-body">
	<article id="post-294" class="post-294 post type-post status-publish format-standard has-post-thumbnail hentry category-development">
		<div class="img-responsive">
			<figure class="imghvr-push-up">
				<img alt="" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" height="210" sizes="(max-width: 360px) 100vw, 360px" src="http://server/wp-content/uploads/2017/02/Team.jpg" srcset="http://server/wp-content/uploads/2017/02/Team.jpg 360w, http://server/wp-content/uploads/2017/02/Team-300x175.jpg 300w" width="360" />
				<h4>Title Text</h4>
				<p><strong>Title Text</strong> Blurb</p>
				<a href="http://server/training-days/"></a>

Open in new window

I am trying to center the image inside the figure html tag. Right now, the image is left justified and I cannot get it to center to save my life. Below is some of the CSS code controlling the elements. If you need more let me know.

/*media all*/
.panel-body {
    padding: 15px;
/*media all*/
article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary {
    display: block;
/*media all*/
.carousel-inner > .item > a > img, .carousel-inner > .item > img, .img-responsive, .thumbnail a > img, .thumbnail > img {
    display: block;
    max-width: 100%;
    height: auto;
/*media all*/
[class^='imghvr-'], [class*=' imghvr-'] {
    position: relative;
    display: inline-block;
    margin: 0px;
    max-width: 100%;
    background-color: #2266a5;
    color: #fff;
    overflow: hidden;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -moz-osx-font-smoothing: grayscale;
    -webkit-transform: translateZ(0);
    transform: translateZ(0px);
/*media all*/
[class^='imghvr-'] > img, [class*=' imghvr-'] > img {
    vertical-align: top;
    max-width: 100%;
/*media all*/
img {
    max-width: 100%;
    height: auto;
    margin: 0 0 10px 0;
/*media all*/
#home-promo1 .panel-body img {
    margin: auto;

Open in new window

Here is a link to the image hover affect website being applied to my image. Not sure if it helps but I want to give some context to what I am working with.

Thanks in advance for any help you can offer. - Joe
Watch Question

Lead Developer
Unlock this solution and get a sample of our free trial.
(No credit card required)


Simple. I was way over-complicating this. Thanks!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.